Simulink Practice
Simulink Practice
Running Simulink
Implementation in Simulink
Implementation in Simulink
Drag&Drop
Implementation in Simulink
• From the ‘Continous’ module choose ‘Transfer Fcn’ (drag
& drop)
• From the ‘Commonly Used Blocks’ choose ‘Scope’
• Merge the blocks with arrows
• Change the ‘Transfer Fcn’ (through double click)
• Optional: change the name of the blocks (double click on
names)
Implementation in Simulink
Run simulation
Double click on
‘Scope’
Implementation in Simulink
• Change the ‘Transfer Fcn’ to 𝑠 2 + 0.1𝑠 + 10 = 0 and run
simulation
Improved accuracy!
Implementation: second method
• Simulate the same system using integrator blocks and
sum by rewriting (B.4):
𝑑 2 𝑣𝑐 𝑑𝑣𝑐
= −4 − 3𝑣𝑐 − 3 𝑢0 (𝑡) (B.7)
𝑑𝑡 2 𝑑𝑡
𝑑 2 𝑣𝑐
• The right side of (B.7) is the sum that yields !
𝑑𝑡 2
• Insert a ‘Sum’ block from the ‘Math Operations’ library (put
3 inputs)
Implementation: second method
• Simulate the same system using integrator blocks and
sum by rewriting (B.4):
𝑑 2 𝑣𝑐 𝑑𝑣𝑐
= −4 − 3𝑣𝑐 − 3 𝑢0 (𝑡) (B.7)
𝑑𝑡 2 𝑑𝑡
𝑑 2 𝑣𝑐
• The right side of (B.7) is the sum that yields !
𝑑𝑡 2
• Insert a ‘Sum’ block from the ‘Math Operations’ library (put
3 inputs)
Implementation: second method
𝑑 2 𝑣𝑐
• Rember: the sum outputs 𝑑𝑡 2
Implementation: second method
𝑑 2 𝑣𝑐
• Integrating 𝑑𝑡 2
we obtain
𝑑𝑣𝑐
𝑑𝑡
𝑑2 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Add a multiply block ‘Gain’ and set it to -4
𝑑2 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Invert the ‘Gain’ (right click on ‘Gain’, then ‘Flip Block’ or
CTRL-I)
𝑑2 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Connect with the output of the integrator
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡
𝑑𝑡 2
Implementation: second method
• Connect to the sum
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡
𝑑𝑡 2
Implementation: second method
• Integrate 𝑑𝑣𝑐
𝑑𝑡
to compute 𝑣𝑐
𝑑𝑣𝑐
𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡
𝑑𝑡 2
Implementation: second method
• Multiply 𝑣𝑐 by -3 and insert into the sum
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Insert the input (step function)
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Multiply the input by 3
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Insert the ‘Scope’ block
𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Now all the signals are inserted in the block diagram:
𝑢0 3𝑢0 𝑑𝑣𝑐
𝑑2 𝑣𝑐 𝑑𝑡 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• The initial conditions are inserted by double clicking the
Integrator blocks and entering the values 0 for the first
integrator, and 0.5 for the second integrator.
𝑑𝑣𝑐
𝑢0 𝑣𝑐
𝑑𝑡
𝑑 2 𝑣𝑐
𝑑𝑡 2
Implementation: second method
• Run the simulation: the result
looks similar with the previous
Implementation!
𝑑𝑣𝑐
𝑢0 𝑣𝑐
𝑑𝑡
𝑑 2 𝑣𝑐
𝑑𝑡 2
Implementation: putting all together
• Copy and paste the first diagram in the same window:
• Find the equation of motion x(t) and perform the simulation with Simulink.
• Optional: use a Matlab file parameters.m to set (all) the input parameters.
• Hints:
1. for the input u(t) use the step function and multiply it by 9.8.
2. The equation is:
𝑑2𝑥 𝐷 𝑑𝑥 𝐾
= − − 𝑥+𝑔
𝑑𝑡 2 𝑀 𝑑𝑡 𝑀