The subplot command allows you to subdivide the graphing window into a grid of m rows and n columns.

The function:


splits the figure into an mn matrix. The variable p identifi es the portion of the window where the next plot will be drawn. For example, if the command


is used, the window is divided into two rows and two columns, and the plot is drawn in the upper left-hand window ( Figure 5.14 ).

The windows are numbered from left to right, top to bottom. Similarly, the follow-ing commands split the graph window into a top plot and a bottom plot:

x = 0:pi/20:2*pi;





The first graph is drawn in the top window, since p1. Then the subplot com-mand is used again to draw the next graph in the bottom window. Figure 5.15 shows both graphs.

Titles are added above each subwindow as the graphs are drawn, as are x – and y -axis labels and any annotation desired.

Leave a Reply

Your email address will not be published. Required fields are marked *