How to use the subplot function in MATLAB?

The subplot function is used to create multiple subplots in one figure window, with the following syntax:

Create a subplot with p in a grid of m rows and n columns.

Among them, m represents the number of rows in the subgraph, n represents the number of columns in the subgraph, and p represents the current position of the subgraph.

For example, if you want to create 4 subplots in a 2×2 grid within one image window and plot data in the first subplot, you can do so using the subplot function.

subplot(2,2,1)
plot(data)

Then you can continue to draw data in other subgraphs, for example:

subplot(2,2,2)
plot(data2)

subplot(2,2,3)
plot(data3)

subplot(2,2,4)
plot(data4)

This method makes it easy to display multiple subplots in one image window for convenient comparison and analysis of relationships between different data.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds