MATLAB: Is it possible to plot multiple equations with different intervals

plot multiple equations intervals

If I have three different equations for example y=x, y=x^2, and y=sqrt(x), is it possible to graph them over three different intervals on the same graph. Like y=x is plotted from 0 to a, y=x^2 is plotted a to b, and y=sqrt(x) is plotted from b to c?

Best Answer

Yes.
For example:
x = [linspace(0,5,25); linspace(5,10,25); linspace(10,15,25)];
y = [x(1,:); x(2,:).^2; sqrt(x(3,:))];
figure(1)
plot(x', y')
grid
produces:
There are probably other ways of doing it, but this works.
Related Question