Multiple independent graphs are drawn in the same graphic window. Different graphs in the same window are called subgraphs.
The Matlab system providesSubplot FunctionTo split the current graph window into several drawing areas. Each region has an independent coordinate system, which is an independent subgraph.
Principle: activate a zone using the subplot function. The zone is the active zone, and all the drawing commands are used in the active zone.
Subplot call format: subplot (m, n, p)
This function divides the current graphic window into M * n drawing areas, that is, m rows, n drawing areas per line, the area number is prioritized by line, and the P area is selected as the current active area.
Example:
For example, the sine, cosine, tangent, and cotangent curves are drawn simultaneously in the form of subgraphs in a graphic window. The program is as follows: x = linspace (* Pi, 60); y = sin (x); Z = cos (x); t = sin (X ). /(COS (x) + EPS); Ct = cos (X ). /(sin (x) + EPS); subplot (2, 2, 1); plot (x, y); Title ('sin (x )'); axis ([* Pi,-]); subplot (, 2); plot (x, z); Title ('cos (x )'); axis ([* Pi,-]); subplot (, 3); plot (x, t); Title ('tangent (x )'); axis ([* Pi,-]); subplot (, 4); plot (x, CT); Title ('coangent (x )'); axis ([0, 2 * Pi,-40, 40]);
Graph window Segmentation