Programming for Engineers (II) - Practical 4: Matlab Simulink Toolbox
Practical 4 Matlab Simulink Toolbox
Practical 4 Matlab Simulink Toolbox (Problem sheet) The goal with the exercises is to get started with some problem solving in Simulink. This is a graphical tool where most of the things also can be done in MATLAB or its other toolboxes, but the need to remember and write all the commands is not necessary. Start MATLAB and write simulink in the command window or click the colourful Simulink symbol. Create and save a new model for each exercise. If you are unsure how to start a new model, please refer to the Simulink lecture that is available on Study Direct.
Exercise 1 Open a new blank model – we are going to place a Pulse Generator, an Integrator and a couple of Scopes (to view both the input and output signals). Drag and drop the blocks onto the model and wire them together. Where did you find each of the blocks? Your model should look something like Figure 1:
Figure 1 Double click on the Pulse Generator to alter the parameters, chose some for amplitude, period and pulse width. Notice that pulse width is a percentage. Run your model and have a look at the input and output signals on the scopes. What do you observe about the system? Change the parameters and run the model again.
Exercise 2 Add some more blocks to your model from exercise 1, add a Derivative and a Scope to view the output signal from the new block. Your model should look something like Figure 2.
Figure 2
Compile your model and have a look at all the signals on the scopes. Change the parameters of the Pulse Generator and observe the changes to the output signals.
Exercise 3 Create a new empty model, add a Ramp input and a Fcn block (this is a user defined function found under User-Defined Functions). Double click on the Fcn block to define the function. We want the function to be sine, see if you can figure out how to set the Fcn block. Add a couple of Scopes to view the input and output signals. Your model should look something like Figure 3.
Figure 3 Compile and run your model. What do you observe on the Scopes? Double click the Ramp and change some of the parameters, re-run your model and observe the changes on the Scopes.
Exercise 4 Add another Fcn block, this time make it a cosine function. Also add a Multiplexer, this can be found under Signal Routing. Connect the outputs of the Fcn blocks to the inputs of the Multiplexor. Connect the output of the Multiplexor to a Scope. Your model should look something like Figure 4.
Figure 4 Compile and run your model. What do you observe on the Scope?
Double click the Ramp and change some of the parameters, re-run your model and observe the changes on the Scope.
Exercise 5 Studying the switch block by building the model shown in Figure 5, you should compare the signals on the scopes 1 and 2. You may modify the sine waves and the switch threshold to obtain other output signals. Sine wave 1 =????? Sine wave 2 =????? Sine wave 3 =sin(?? − 0.5?)
Figure 5 Switch block set
Exercise 6 Building the model shown in Figure 6, study the outputs of a transfer function with and without PID control. The controller values are shown in Figure 7. The signals are displayed for 10 seconds on scopes, how to increase the simulation time?