stepplot: Add curve to subplot of step response

5 ビュー (過去 30 日間)
Ced
Ced 2015 年 11 月 2 日
コメント済み: Ced 2015 年 11 月 5 日
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!

採用された回答

Tushar Sinha
Tushar Sinha 2015 年 11 月 4 日
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 件のコメント
Ced
Ced 2015 年 11 月 5 日
Just what I was looking for, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by