MATLAB: Plot a variable with different values at different time intervals.

plottime interval

Hi
I have a table below that assigns different values of r at different time interval. How can I do this please?
Screen Shot 2019-01-30 at 2.27.10 PM.png

Best Answer

Logical indexing is more efficient :
t=0:.001:8;
r=zeros(size(t));
r(t>=0 & t<1)=100;
r(t>=1 & t<4)=250;
r(t>=4 & t<6)=330;
r(t>=6 & t<8)=100;
r(t==8)=0;
plot(t,r)
Related Question