MATLAB: How to plot a selective range of x-axis values

plotting

I am a new user of MATLAB. Currently I have this in my script:
figure
subplot(2,2,1)
plot(t/60,mass)
grid on
title('Mass dried')
xlabel('Time, t (min)')
ylabel('Mass dried, g')
This plots time in minutes on the x-axis, where "t" is the time vector in seconds returned from the function pdepe(m,@solnpde,@solnic,@solnbc,r,t,options). The solution to the pde is from t = 0 to t = 1800.
Please advise how I can plot the graph for values of t from:
1. t = 0 to t = 600
2. t = 600 to t = 1200.
Many thanks,
Doug

Best Answer

your 't' and 'm' must be the same size; open the variable 't' from Workspace and look what index contains the value of ~600. Let's say the index is 20. Thus, you want to use a part of 'time' array from index 1 to 20. Similarly, you find what index corresponds to value of 1200. If it you found it to be equal let's say 40, then you need to use t[21:40]
subplot(2,1,1)
plot(t(1,1:20),m(1,1:20));
subplot(2,1,2)
plot(t(1,21:40),m(1,21:40));
Of course, there is a way to find corresponding indecies automatically, but if you are planning to use it once, it is easier just to look up for the each index yourselves.
I think here is the way to find'em automatically:
t_temp=t;
t_temp=t_temp-600;
t_temp=abs(t_temp);
index600=find(t_temp==(min(t_temp)),1,'first');
same for the other:
t_temp=t;
t_temp=t_temp-1200;
t_temp=abs(t_temp);
index1200=find(t_temp==(min(t_temp)),1,'first');
subplot(2,1,1)
plot(t(1:index600),m(1:index600));
subplot(2,1,2)
plot(t(index600:index1200),m(index600:index1200));
Now, I hope, this answer is deserved to be accepted.