# Multiplot in matlab

1. Sep 24, 2011

Dear Fellows,

I need to plot a graph in matlab, and stuck in obtaining multi plot from it for different constant values... following example will explain my situation.

x=1;
y=3;
c=x^2+4y+9z
z=linspace(0,1.2);
plot(z,c,'r')
in this I want to plot for y=3,y=4,y=5 and y=0 all curves in one graph.

2. Sep 24, 2011

### jhae2.718

Use the "hold on;" command and multiple plot statements.

3. Sep 26, 2011

For different plot I need to past the whole program and change the only variable(y) and
plot(x,y,'r')
hold on
plot(x,y1,'r--')
hold on
plot(x,y2,'b')
Is this what you are saying?

can you please give small example so that I can understand clearly...

4. Sep 26, 2011

### mikeph

small example,

x = 0:0.1:10;
y1 = x^2 + 2x + 1;
y2 = x^2 + 4x + 1;

so you have two curves, y1 and y2.

plot(x,y1,'r');
hold on
plot(x,y2,'b');

this will plot y2 on the same axis as y1. you only need to type hold on once; after you type it, all further curves are put on the same plot.