stepplot: Add curve to subplot of step response
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Plot Customization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!