for system dynamics & control
DESCRIPTION
For System Dynamics & Control. By Dr. Hong Zhang. Start Matlab. Free Matlab Clones. Octave http://www.gnu.org/software/octave/ Very Similar commands Can run most M-files No built-in Simulink package Pure command line . Free Matlab Clones. Scilab http://www.scilab.org/ - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/1.jpg)
For System Dynamics
& ControlBy Dr. Hong Zhang
![Page 2: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/2.jpg)
Start Matlab
![Page 3: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/3.jpg)
Octave◦ http://www.gnu.org/software/octave/◦ Very Similar commands◦ Can run most M-files◦ No built-in Simulink package◦ Pure command line
Free Matlab Clones
![Page 4: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/4.jpg)
Scilab◦ http://www.scilab.
org/◦ Some commands
are different◦ Built-in Xcos to
clone Simulink◦ Some Graphic
interface
Free Matlab Clones
![Page 5: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/5.jpg)
Given a transfer function a2s2 + a1s + a0
b2s2 + b1s + b0We can define it in Matlab as
num = [a2, a1, a0];den = [b2, b1, b0]; sys = tf(num, den);
Transfer Function
![Page 6: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/6.jpg)
Unit step responsestep(sys)
Unit impulse responseimpulse(sys)
Arbitrary input responset = tstart: tinterval : tfinish;u = f(t); % u is a function of t, e.g. ramp is u=t;lsim(sys, u, t)
Plot Transient Response
![Page 7: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/7.jpg)
Just bring the output to a variable. E.g.y1 = step(sys);y2 = impule(sys);y3 = lsim(sys, u, t);
Then we can use the variable. E.g. plot(t,y1, t, y2)
plot(t, u, t, y3)
Response As a Variable
![Page 8: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/8.jpg)
[r, p, k] = residue(num, den);Where
r: rootp: polek: constant
If there are complex terms, we can add the two conjugate ones together to get a 2nd order real term.
Partial Fractional Expansion
![Page 9: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/9.jpg)
Click the Simulink icon in Matlab window
Start Simulink
Simulink library browserSimulink modeling window
Matlab main window
![Page 10: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/10.jpg)
Find, drag and drop following blocks to the window◦ Simulink Continuous Transfer Function◦ Sources Step◦ Sinks ScopeYou will get
Transfer Function
Building Blocks
OutputInput
Except sources and sinks, every block should have an input and an output.
![Page 11: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/11.jpg)
Double click the Transfer function block.
Modify Transfer Function
Change Numerator to [1], denominator to [1 3 2]
![Page 12: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/12.jpg)
Link the blocks by drag the output to input Double click Scope to show Scope window Click Ctrl+T or SimulationStart or button
Run Simulation
![Page 13: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/13.jpg)
Change the spring constant and damping ratio, then you can have different response.
Modify System
[1 2 12][1 2 1]Hint: Hit the binocular to auto-scale the plot.
![Page 14: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/14.jpg)
Replace the source with a Sine wave with frequency =3
Sinusoidal Response
Hint: Double click the block name to change it.
![Page 15: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/15.jpg)
Hint: ◦ Hold Ctrl and click to tap an output line◦ Right click a block and select Format to flip or rotate a block
Flowchart with Feedback
![Page 16: For System Dynamics & Control](https://reader036.vdocument.in/reader036/viewer/2022062222/5681611f550346895dd0792f/html5/thumbnails/16.jpg)
Mass-Spring-Damper Modeling
€
m˙ ̇ x + c ˙ x + kx = f ( t)
€
˙ ̇ x = 1m [ f (t)− c ˙ x − kx]
Rewrite
as
Assumem=2kgc=3NSec/mk=3N/mf(t)=1(t)N