MATLAB: Plotting different functions at the end of eachother

logical indexingplotting

I have 2 functions one for 0<x<10 and one for 10<x<30. How do i plot the second one at the point where the first one ends?

Best Answer

fz10 = @(x)x+3;%two functions
f1030 = @(x)(x+3)*2;
t = 0:20;
plot(t(t<10),fz10(t(t<10)),'r*',t(t>10&t<30),f1030(t(t>10&t<30)),'b*') %logical indexing!