Simulating a plant in Simulink

29 views (last 30 days)
Caio
Caio on 13 Nov 2023
Answered: Paul on 14 Nov 2023
I decided to learn simulink and matlab since I'm interested in control engineering, been trying to solve some simple problems and this one in particular has been quite troublesome. Can anyone point me in the right direction? What am I doing wrong?
This is what I've been trying to simulate:
This is what I've done in simulink:
Quite unsure about the results of the simulation.
I solved that so I have values for T but still simulating it isn't as simple as it seemed. For stability 0 < T < 0.2 if T > 0.2 it's unstable
  2 Comments
Paul
Paul on 14 Nov 2023
Hi Caio,
Why are you unsure about the results of the simulation?
Caio
Caio on 14 Nov 2023
Edited: Caio on 14 Nov 2023
Cause I'm unsure if what I simulated is actually what was in the block diagram. I tried following it but couldn't find some of the blocks in simulink, i.e the T, also was quite unsure how to do the ZOH block so I assumed that the one I used would be it. Maybe I'm making it complicated idk. Just trying simulink out, I read the docs but couldn't find anything to shine a light on this one.

Sign in to comment.

Answers (1)

Paul
Paul on 14 Nov 2023
The Zero-Order Hold block with Sample Time parameter set to an expression that evaluates to the sampling period T does the sample and hold operation in the first block diagram. Looks like the Simulink model is ok.
We can compare the Simulink model to Control System Toolbox, for T = 0.2.
P = tf(10,[1 1]);
T = 0.2;
H = feedback(c2d(P,T,'zoh'),1);
t = 0:T:8;
y = lsim(H,t>=1);
figure
plot(t,y,'-o')
The difference betwee the CST and Simulink is that Simulink is using its ode solver to compute the output of the plant, potentially between the sampling times depenending on the solver settings, whereas this CST code is approximating the plant with a discrete-time approximation and only computes the output at the sample times. But the Simullink and CST results are very close at the sample times for the given sampling period.

Categories

Find more on General Applications in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!