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

 Akzeptierte Antwort

dpb
dpb am 8 Jan. 2015

2 Stimmen

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 Kommentare

m
m am 9 Jan. 2015
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
dpb
dpb am 9 Jan. 2015
The simplest is to use q instead of t as the independent variable with the y vector as above.
plot(q,y)
m
m am 9 Jan. 2015
ok.thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

m
m
am 8 Jan. 2015

Kommentiert:

m
m
am 9 Jan. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by