Partial plot in the same figure

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

 采纳的回答

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)
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