Getting Started With Simulink
Getting Started With Simulink
1
Launch Simulink
In the MATLAB command window,
at the >> prompt, type simulink
and press Enter
2
Create a new model
Click the new-model
icon in the upper left
corner to start a new
Simulink file
Select the Simulink
icon to obtain
elements of the
model
3
Your workspace
Library of elements Model is created in this window
4
Save your model
You might create a new folder, like the one
shown below, called simulink_files
Use the .mdl suffix when saving
5
Example 1: a simple model
Build a Simulink model that solves the
differential equation
x 3 sin 2t
Initial condition x(0) 1.
First, sketch a simulation diagram of
this mathematical model (equation)
(3 min.)
6
Simulation diagram
Input is the forcing function 3sin(2t)
Output is the solution of the differential
equation x(t) x(0) 1
x 1 x
3sin(2t) x(t)
s
(input) (output)
integrator
8
Select an operator block
Drag an Integrator block
from the Continuous library
to the model window
9
Select an output block
Drag a Scope block from the
Sinks library to the model
window
10
Connect blocks with signals
Place your cursor on
the output port (>) of
the Sine Wave block
Drag from the Sine
Wave output to the
Integrator input
Drag from the
Integrator output to
the Scope input Arrows indicate the
direction of the signal flow.
11
Select simulation parameters
Double-click on
the Sine Wave
block to set
amplitude = 3
and freq = 2.
12
Select simulation parameters
Double-click on
the Integrator
block to set
initial condition
= -1.
13
Select simulation parameters
Double-click on
the Scope to view
the simulation
results
14
Run the simulation
In the model
window, from the
Simulation pull-
down menu,
select Start
mx cx kx f (t )
17
Create the simulation diagram
On the following slides:
The simulation diagram for solving the ODE
is created step by step.
After each step, elements are added to the
Simulink model.
Optional exercise: first, sketch the
complete diagram (5 min.)
mx cx kx f (t )
18
(continue)
First, solve for the term with highest-
order derivative
mx f (t ) cx kx
Make the left-hand side of this equation
the output of a summing block
mx
summing
block
19
Drag a Sum block from
the Math library
20
(continue)
Add a gain (multiplier) block to
eliminate the coefficient and produce
the highest-derivative alone
mx 1 x
m
summing
block
21
Drag a Gain block from
the Math library
22
(continue)
Add integrators to obtain the desired
output variable
mx 1 x 1 x 1 x
m s s
summing
block
23
Drag Integrator blocks from
the Continuous library
mx 1 x 1 x 1 x
m s s
summing cx
block c
kx k
25
Drag new Gain blocks
from the Math library
To flip the gain block, select it
and choose Flip Block in the
Format pull-down menu.
c=0.5
Double-click on gain blocks to
set parameters
Connect from the gain block
input backwards up to the
branch point. k=1.0
Re-title the gain blocks.
26
Complete the model
Bring all the signals and inputs to the
summing block.
Check signs on the summer.
28
Final Simulink model
29
Run the simulation
30
Results
Underdamped response.
Overshoot of 0.5.
Final value of 3.
Is this expected?
31