2. Introduction to Simulink
โขSimulink is a commercial tool for modeling, simulating and
analyzing dynamic systems.
โขIts primary interface is a graphical block diagramming tool
and a customizable set of block libraries.
โขIt offers tight integration with the rest of the MATLAB
environment and can either drive MATLAB or be scripted
from it.
โขSimulink is widely used in control theory and digital signal
processing for simulation and design.
โขA dynamic system may be given as a differential equation
11. โข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
13. Accuracy of the solution depends on
- Solver (numerical integration algorithm)
- Step size
โขChange the โTransfer Fcnโ to ๐ 2 + 0.1๐ + 10 = 0 and run
simulation
Implementation in Simulink
17. Implementation: second method
โขSimulate the same system using integrator blocks and
sum by rewriting (B.4):
๐2๐ฃ๐
๐๐ก2 = โ4
๐๐ฃ๐
๐๐ก
โ 3๐ฃ๐ โ 3 ๐ข0(๐ก) (B.7)
โขThe right side of (B.7) is the sum that yields
๐2๐ฃ๐
๐๐ก2 !
โขInsert a โSumโ block from the โMath Operationsโ library (put
3 inputs)
18. Implementation: second method
โขSimulate the same system using integrator blocks and
sum by rewriting (B.4):
๐2๐ฃ๐
๐๐ก2 = โ4
๐๐ฃ๐
๐๐ก
โ 3๐ฃ๐ โ 3 ๐ข0(๐ก) (B.7)
โขThe right side of (B.7) is the sum that yields
๐2๐ฃ๐
๐๐ก2 !
โขInsert a โSumโ block from the โMath Operationsโ library (put
3 inputs)
30. Implementation: second method
โขNow all the signals are inserted in the block diagram:
๐๐ฃ๐
๐๐ก ๐ฃ๐
๐ข0
๐2๐ฃ๐
๐๐ก2
3๐ข0
31. 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.
๐2๐ฃ๐
๐๐ก2
๐๐ฃ๐
๐๐ก ๐ฃ๐
๐ข0
32. Implementation: second method
โขRun the simulation: the result
looks similar with the previous
Implementation!
๐2๐ฃ๐
๐๐ก2
๐๐ฃ๐
๐๐ก ๐ฃ๐
๐ข0
33. Implementation: putting all together
โขCopy and paste the first diagram in the same window:
This block do no accept
initial conditions!
38. Exercise 1
โข Following the same steps, simulate the following dynamic
system:
๐๐ฅ
๐๐ก
+ 2๐ฅ ๐ก = ๐ข(๐ก)
where ๐ข(๐ก) is a square wave with an amplitude of 1 and a
frequency of 1 rad/sec and ๐ฅ ๐ก is the output of the system.
To generate a Square Wave use a โSignal Generatorโ block and
select the Square Wave form but change the default units to
radiants/sec.
โข Method 1: use a single block for the transfer function
โข Method 2: use an โIntegratorโ block, a โGainโ block and a โSumโ
block.
โข What do you note in the absence of initial conditions?
โข Hint: type โModel a Continuous Systemโ in the Help search of
Matlab.
39. Exercise 2
โขFor the following mass-spring-damper system, the inputs
are:
โข M = 1Kg (mass)
โข u = the gravity force Mg (g = 9.8)
โข K = 5.0 N/m (spring constant)
โข D = 0.05 Ns/m (damping coefficient)
โข x(0) = 10 (initial position)
โข xโ(0) = 0 (initial velocity)
โข 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
= โ
๐ท
๐
๐๐ฅ
๐๐ก
โ
๐พ
๐
๐ฅ + ๐