what is subplot and how to use it?
이전 댓글 표시
i want to plot two graphs in one single window then how to do so? what is block? also give some hint on how join various elements and blocks while using simulink?
채택된 답변
추가 답변 (2개)
Benjamin Kraus
2023년 10월 30일
편집: Benjamin Kraus
2024년 7월 2일
If you are using MATLAB R2019b or later, you should consider using tiledlayout and nexttile instead of subplot. tiledlayout and nexttile supports most of the features of subplot, and many more, and you should see better performance with tiledlayout and nexttile.
The tile layout is the same as subplot, but tiledlayout also supports a "flow" layout that will automatically adjust the number of rows and columns to optimally fit your axes. In addition, since MATLAB R2023a you can specify a "vertical" or "horizontal" layout that will stack your axes vertically or horizontally.
The equivalent to subplot(3, 4, plotNumber); with tiledlayout would be this:
tiledlayout(3,4)
nexttile(plotNumber)
댓글 수: 2
Sagnik
2024년 7월 2일
minor typo .. it should be nexttile (not nextile)
Benjamin Kraus
2024년 7월 2일
@Sagnik: Thanks. I've fixed it.
Matt Fig
2012년 10월 5일
figure
subplot(1,2,1)
plot(1:10)
subplot(1,2,2)
plot((1:10).^2)
help subplot
댓글 수: 5
monali
2012년 10월 7일
Prabin Rath
2018년 6월 7일
1 to 10 with a spacing of 1. Like 1,2,3,4....
Olivier GARRIGUES
2023년 10월 6일
Its the number of the plot, from top to bottom and left to right. So if you have a 1 by 2 plot, subplot(1,2,1) is the left one and subplot(1,2,2) the right one.
Image Analyst
2023년 10월 6일
@Asim the first two numbers are the number of rows and columns in the layout of all the plots in a grid. The third number is the "number" of the particular single plot that is in the grid. For example if you have 3 rows and 4 columns, this chart gives the third number:
1 2 3 4
5 6 7 8
9 10 11 12
So for example if you wanted to make a plot in the second row and third column, that would be #7, so you'd do this
subplot(3, 4, 7)
and if you wanted to plot something in the third row, second column, that would be #10 and you'd call this before you called plot:
subplot(3, 4, 10);
Does that explain it better?
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!