MATLAB graphics drawing-sub-graph

Subgraph

Sub figure is more than one image to be displayed on a picture, draw subgraph command subplot(m,n,p)command, here m,nto tell MATLABsubgraph generated have mrows ncolumns, ptell MATLABa graphic window has drawn us to be posted up.
The first example we show side by side the two functions:
Function 1
Function 2
in both cases, we are located xin 0~5between, yin -1~1between, we first define domain-defined function, and then call the functionsubplot

>> x = [0:0.01:5];
>> y1 = exp(-1.2*x).*sin(20*x);
>> subplot(1,2,1)

Pass subplotus (1,2,1), telling MATLABus that we will create an image with one row and two columns, and the next drawing will be displayed in the first pane, but no image has been drawn yet:
The plot command is not called
now we call the plotcommand :
Call the first plot

Looking at the picture now, the image of the function has been drawn in the first pane.
Next we create a second image, first we define the function:

>> y2 = exp(-2*x).*sin(20*x);

Now we call subplot, this time tell MATLABus that we will draw the graph on the second pane:
Second pane
at this time, we MATLABhave not put anything on it, at this time we want to call the plotcommand:

>> plot(x,y2),xlabel('x'),ylabel('exp(-2x)*sin(20x)'),axis([0 5 -1 1])

image:
subplot

Published 84 original articles · won 18 · views 5805

Guess you like

Origin blog.csdn.net/qq_44486550/article/details/105232028