Why Does My Plot Not Match My Numbers?
2 views (last 30 days)
Show older comments
Hi all,
I am not fluent in matlab nor this community, so I apologise if this is not the right place to ask this question. However I'm trying to plot the velocity error of a transfer function multiplied by a proportional control (nonzero constant). My calculations show that the velocity error should be a nonzero constant, however it appears as though the error tends to infinity as t tends to infinity. I'm more confident in my math, than I am in my coding of matlab, so I think the issue is on the coding side. If I am flawed in my approach, it would be greatly appreciated if someone could point it out.
Essentially the code being used.
s = tf('s');
gs = k*(a*s + b) / (s^3 + c*s^2 + d*s)
Kp = 3.7
cl_lp_err = feedback(1, Kp*gs) %Creating an error closed loop system
t = 0:0.1:200;
figure(1)
hold on
step(1/(s*cl_lp_err))
hold off
figure(2)
hold on
plot(t, 1*t)
hold off
2 Comments
Answers (1)
Sam Chak
on 14 May 2022
Since the values for the parameters are not provided, they are assumed in the following, which should give you a general idea on how to work out the problem. I'm unsure, but the syntax in your feedback appears to be incorrect. Better provide the math since it will clarify everything.
% parameters (assumed)
a = 1;
b = 1;
c = 1;
d = 1;
k = 1/3.7;
% the Laplace variable
s = tf('s');
% Transfer function of the system in open loop
gs = k*(a*s + b) / (s^3 + c*s^2 + d*s)
% proportional gain
Kp = 3.7;
% Transfer function of the closed-loop system
gcl = feedback(Kp*gs, 1)
% step response of the closed-loop system
step(gcl)
% if you want to simulate until 200 sec
step(gcl, 200)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!