help subplot
SUBPLOT Create axes in tiled positions
SUBPLOT(m,n,p) divides the current figure into an m-by-n grid and
creates an axes in the position specified by p. MATLAB® numbers subplot
positions by row. The first subplot is the first column of the first
row, the second subplot is the second column of the first row, and so
on. If an axes exist in the specified position, then this command makes
the axes the current axes.
SUBPLOT(m,n,p,'replace') deletes the existing axes in position p and
creates a new axes.
SUBPLOT(m,n,p,'align') creates a new axes so that the plot boxes are
aligned. This option is the default behavior.
SUBPLOT(m,n,p,ax) converts the existing axes, ax, into a subplot
in the same figure.
SUBPLOT('Position',pos) creates an axes in the custom position
specified by pos. Use this option to position a subplot that does not
align with grid positions. Specify pos as a four-element vector of the
form [left bottom width height]. If the new axes overlaps existing
axes, then the new axes replaces the existing axes.
SUBPLOT(___,Name,Value) modifies axes properties using one or more
name-value arguments. Set axes properties after all other input
arguments.
ax = SUBPLOT(___) creates an Axes object, PolarAxes object, or
GeographicAxes object. Use ax to make future modifications to the axes.
SUBPLOT(ax) makes the axes specified by ax the current axes for
the parent figure. This option does not make the parent figure the
current figure if it is not already the current figure.
Example:
subplot(2,1,1);
x = linspace(0,10);
y1 = sin(x);
plot(x,y1)
subplot(2,1,2);
y2 = sin(5*x);
plot(x,y2)
See also TILEDLAYOUT, NEXTTILE, SGTITLE, AXES, GCA
Documentation for subplot
doc subplot