天天百科

matlab中怎么同时存在多个子窗口

2023-07-02 分类:百科

TIPS:本文共有 574 个字,阅读大概需要 2 分钟。

用matlab创建多个窗口的函数是subplot()函数。subplot()函数使用格式:

subplot(m,n,p)

该命令函数的意思是,将当前图窗划分为m×n网格,并在p指定的位置创建坐标区。MATLAB按行号对子图位置进行编号。第一个子图是第一行的第一列,第二个子图是第一行的第二列,依此类推。如果指定的位置已存在坐标区,则此命令会将该坐标区设为当前坐标区。

那如何使用,请看下列例子:

subplot(2,2,1) %创建2行2列子窗口,在第1行第1子窗显示

x = linspace(0,10)

y1 = sin(x)

plot(x,y1)

title('Subplot 1: sin(x)')

subplot(2,2,2)%创建2行2列子窗口,在第1行第2子窗显示

y2 = sin(2*x)

plot(x,y2)

title('Subplot 2: sin(2x)')

subplot(2,2,3)%创建2行2列子窗口,在第2行第3子窗显示

y3 = sin(4*x)

plot(x,y3)

title('Subplot 3: sin(4x)')

subplot(2,2,4)%创建2行2列子窗口,在第2行第4子窗显示

y4 = sin(8*x)

plot(x,y4)

title('Subplot 4: sin(8x)')

如果觉得《matlab中怎么同时存在多个子窗口》对你有帮助,请点赞、收藏,并留下你的观点哦!

阅读剩余内容
网友评论
相关阅读
小编推荐