subplots in matlab code example

Example 1: 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 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 title matlab

suptitle('I am a super title')

Tags:

Misc Example