subplot matlab code example
Example 1: clf subplot matlab
h1 = subplot(2,1,1);
hold on
x1=(0:0.01:10);
y1=sin(x1);
p1=plot(x1,y1);
h2 = subplot(2,1,2)
hold on
x1=(0:0.01:10);
y2=sin(x1)+cos(x1);
p2=plot(x1,y2,'Color','r');
cla(h2)
cla(h1)
Example 2: subplot
subplot(m,n,p) %Creates subplot of m rows and n columns and assigns to plot in
p index of mxn subplot matrix.
Example 3: subplot matlab
subplot(2,2,1)
x = linspace(0,10);
y1 = sin(x);
plot(x,y1)
title('Subplot 1: sin(x)')
subplot(2,2,2)
y2 = sin(2*x);
plot(x,y2)
title('Subplot 2: sin(2x)')
subplot(2,2,3)
y3 = sin(4*x);
plot(x,y3)
title('Subplot 3: sin(4x)')
subplot(2,2,4)
y4 = sin(8*x);
plot(x,y4)
title('Subplot 4: sin(8x)')
Example 4: subplot title matlab
suptitle('I am a super title')