Filter löschen
Filter löschen

Plotting system outputs together with different time intervals for each system? HELP!

2 Ansichten (letzte 30 Tage)
Hello everyone,
I have 5 state space systems (time domain) that I'm trying to plot.
sys1 should run from t = 0 to t = a and after t=a the magnitude should be 0.
sys2 should run from t = 0 to t = b (where b > a) and after t=b the magnitude should be 0.
The same goes for sys3 sys4 and sys5 (t = c, d, e respectively where e>d>c>b>a).
Does anyone have any ideas how I can restrict the system outputs in the plot area?
Here is my code:
% Create the step responses for the Transfer Function & Simulink systems
t = linspace(0,t_cutoff,51);
y1 = step(sys1,t);
y2 = step(sys2,t);
y3 = step(sys3,t);
y4 = step(sys4,t);
y5 = step(sys5,t);
% Plot these step responses vs. time
plot(t,y1,'ro',t,y2,'b-',t,y3,':squarek',t,y4,'-*g',t,y5,'-xb'),grid
My code definitely works thus far, it plots all of the functions but it plots them longer than the intervals they are supposed to cover (i.e. system 1's only sensible operation range is between t=0 and t=a, no other interval is even feasible)
Any help you can contribute is greatly appreciated! Thank you!
-Alex

Antworten (1)

Sam Chak
Sam Chak am 2 Sep. 2023
The lsim() function offers better control than the step() function.
t = 0:0.001:15;
Ts = [1 2 3 4 5];
w = 4./Ts;
for j = 1:length(w)
G = tf(w(j), [1 w(j)]);
u = heaviside(t) - heaviside(t - (Ts(j) + 2));
lsim(G, u, t), hold on
end
hold off, grid on
legend('G1', 'G2', 'G3', 'G4', 'G5')

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by