Hello,
Say i have an array of ap[10] and ap2[10]. i want to plot partial with respect of plot(t,ap) and plot(t,ap2) in the same axis where t=22. the first ap will start from t=0 until t=10, where t=11 & 12 is blank. then ap2 will continue to plot from t=13 until end.
is it possible to do so?
thanks

 채택된 답변

dpb
dpb 2015년 1월 8일

2 개 추천

Not positive I follow precisely, but taking a guess of what you mean...excepting you're got a disconnect in that if length(ap)=10, then the number of values between 0:10 is 11 unless you use
t1=linspace(0,10,0); % rather than 0:10
But, on the assumption really want 1:10 to go with the 10 values,
plot(1:10,ap,'k-')
hold on
plot(13:22,ap2,'k-')
will do it. Or, a little more elegantly, perhaps would be
y=[ap nan nan ap2]; % assume are row vectors
t=[0:length(y)-1]; % a time vector
plot(t,y)
The NaN in the vector y will not be plotted but the time vector increases unbroken.

댓글 수: 3

thank you for the solution, i never thought it would be this simple...
but, slight problem with value for x axis, i already set it with
q=0:0.15:3.15; %time
so, how can i change it to these?
thanks
The simplest is to use q instead of t as the independent variable with the y vector as above.
plot(q,y)
m
m 2015년 1월 9일
ok.thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

m
m
2015년 1월 8일

댓글:

m
m
2015년 1월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by