stepplot: Add curve to subplot of step response

6 vues (au cours des 30 derniers jours)
Ced
Ced le 2 Nov 2015
Commenté : Ced le 5 Nov 2015
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!

Réponse acceptée

Tushar Sinha
Tushar Sinha le 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
  1 commentaire
Ced
Ced le 5 Nov 2015
Just what I was looking for, thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Plot Customization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by