Simulink
Simulink
What is Simulink?
Simulink is a visual programming interface designed to make modelling systems intuitive. It
offers a way to solve equations numerically using a graphical user interface, rather than
requiring code.
Text Annotation
Blocks
Signal and Labels
where the > signs denote the inputs and outputs of a block, which can be connected to other
blocks.
c) Click the Blank Model icon, highted in figure 4. It will open the Simulink Editor.
d) From the Simulation tab, select Save > Save as. In the File name text box, enter a
name for your model. For example, simple_model. Click Save. The model is saved with
the file extension .slx.
a) From the Simulation tab, click the Library Browser button . The Simulink library
browser will top up as shown in figure 6.
Figure 6: Simulink library browser.
b) To browse through the block libraries, select a category and then a functional area in
the left pane. To search all the available block libraries, enter a search term.
For example, to find the Pulse Generator block, in the search box on the browser toolbar,
enter pulse, and then press Enter. Simulink searches the libraries for blocks with pulse in their
name or description and then displays the blocks.
Add all other required blocks to your model using the same approach. Arrange the blocks by
clicking and dragging each block. To resize a block, drag a corner.
4. Connect Blocks
Connect the blocks by creating lines between output ports and input ports.
Figure 9: Connecting blocks.
5. Run Simulation
After you define the configuration parameters, you are ready to simulate your model.
a) In the Simulation tab, set the simulation stop time (seconds) by changing the value in
the toolbar. The default stop time is 10.0 seconds. This time value could have time
units in milliseconds or years.
b) To run the simulation, click the Run button . The simulation runs and produces
the output in the viewer.
Blocks required:
• Signal generator
• Gain
• Scope
• To workspace
1. Signal generator: In the parameters of signal generator select the type of signal wave you
want to use. In this example, select sine wave. Then set the amplitude “3” and frequency “1”
of the signal. Select Hz as a unit of frequency. After setting all parameters, click on apply and
then OK.
2. Gain: This block is used to amplify the signal by multiply it with any number “n”. Double click
on the block and set the gain value at 2.
Figure 13: Block parameters of Gain.
3. Scope: As we want to plot both the original and amplified signals in scope, open the block
and select 2 for the number of input ports as shown in figure below.
4. To Workspace: The use of this block is to export results to MATLAB workspace. In the block
parameters, set the variable name and the name will be exported to MATLAB workspace. In
this example, you need two (2) To Workspace blocks for the original and amplified signals. Set
the variable name for the original signal as “x” and amplified signal as “nx”.
Figure 15: Block parameters of "to workspace" block.
To plot the signal, use the following commands on MATALB Command Window:
>> hold on
Assign parameter values to the Gain and Constant blocks by opening (double-clicking) each
block and entering the appropriate value. Then, click the OK button to apply the value and
close the dialog box.
Now, connect the blocks.
The Ramp block inputs Celsius temperature. Open that block and change the Initial
output parameter to 0. The Gain block multiplies that temperature by the constant 9/5. The
Sum block adds the value 32 to the result and outputs the Fahrenheit temperature.
Open the Scope block to view the output. Now, choose Run from the Simulation menu to run
the simulation. The simulation runs for 10 seconds.
Some useful videos:
1) https://uk.mathworks.com/videos/getting-started-with-simulink-part-1-building-and-
simulating-a-simple-simulink-model-1508442030520.html
2) https://uk.mathworks.com/videos/getting-started-with-simulink-69027.html
3) https://uk.mathworks.com/products/simulink.html
4) https://uk.mathworks.com/videos/calling-simulink-from-matlab-97334.html?s_tid=srchtitle