using hold on function in step response with subplot
39 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BALA GUGA GOPAL S
am 24 Feb. 2019
Kommentiert: BALA GUGA GOPAL S
am 26 Feb. 2019
I am trying to plot step reponse and impulse reponse of a sys in a single plot,using suplot and lengend, but i too have different values of z to be ploted (means i am using hold on fun). when i try to use subplot with the created code it's plotting for only one value of z, but i want such that all the three values of z has to plotted for both the step and impulse function in subplot, I apperciate your help.
s=tf('s');
z=[3 6 12];
hold on
for i=1:3
zc=z(i);
g=(15/zc)*((s+zc)/(s^2+3*s+15));
subplot(2,1,1)
step(g)
subplot(2,1,2)
impulse(g)
end
legend('z = 3','z = 6','z = 12')
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
GMD Baloch
am 24 Feb. 2019
You just have to a little bit of modification in your code. I have done it and it is producing the following result
I hope that you wanted the above output. The modified code is given below
s=tf('s');
z=[3 6 12];
for i=1:3
zc=z(i);
g=(15/zc)*((s+zc)/(s^2+3*s+15));
subplot(2,2,i)
step(g)
hold on
impulse(g)
legend('z = 3','z = 6')
end
6 Kommentare
GMD Baloch
am 26 Feb. 2019
You can try the following code
s=tf('s');
z=[3 6 12];
subplot(2,1,1)
hold on
for i=1:3
zc=z(i);
g=(15/zc)*((s+zc)/(s^2+3*s+15));
step(g)
end
legend('z = 3','z = 6','z = 12')
subplot(2,1,2)
hold on
for i=1:3
zc=z(i);
g=(15/zc)*((s+zc)/(s^2+3*s+15));
impulse(g)
end
legend('z = 3','z = 6','z = 12')
The output for this code is shown below
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!