stepplot: Add curve to subplot of step response
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
I have a system with 1 input and 3 outputs for which I visualize the step response using stepplot, which returns a plot handle. However, I don't understand the plot handle object it returns.
What I would like to do is the following:
Create a step response (resulting in 3 "subplots"), and then manually plot another curve in the three subplots for comparison.
So, something like this:
% plot this dummy system with stepplot
A = -10;
B = 1;
C = [ 5 2 1 ]';
s = tf('s');
sys = C*inv(s-A)*B;
% have some other dummy plot I also want to add for comparison
t = 0:0.01:1;
y1 = 0.5*(1-exp(-10*t));
y2 = 0.2*(1-exp(-10*t));
y3 = 0.1*(1-exp(-10*t));
% stepplot
figure(1)
handle = stepplot(sys);
% overlay other plots (this is the part I cannot figure out)
plot(handle(1),y1,'LineStyle','--')
plot(handle(2),y2,'LineStyle','--')
plot(handle(3),y3,'LineStyle','--')
Thanks!
0 Commenti
Risposta accettata
Tushar Sinha
il 4 Nov 2015
Hi Ced,
You can do the manual plotting of other curves on the subplots by making use of the "getaxes" property of the handle object returned by "stepplot". Please make sure that the overlay values are within the range of the x,y axis limits of the original subplots. Here is how you can achieve this programmatically:
% plot this dummy system with stepplot
A = -10;
B = 1;
C = [ 5 2 1 ]';
s = tf('s');
sys = C*inv(s-A)*B;
% have some other dummy plot I also want to add for comparison
t = 0:0.01:1;
y1 = 0.5*(1-exp(-10*t));
y2 = 0.2*(1-exp(-10*t));
y3 = 0.1*(1-exp(-10*t));
% stepplot
figure(1)
handle = stepplot(sys);
hold all;
AxArray = handle.getaxes;
x=0.1:0.1:0.9
y = 0.2*ones(size(x));
plot(AxArray(1),x,y,'r','LineStyle','--');
plot(AxArray(2),x,y,'r','LineStyle','--');
plot(AxArray(3),x,y,'r','LineStyle','--');
I hope this helps answer your question.
Thanks,
Tushar
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Plot Customization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!