Chapter5 图形绘制(三)
一、绘图控制
1 subplot( )
在绘图过程中,我们常需要在一个窗口中并行显示多幅图像,subplot() 可以将窗口分为多个子图。
语法格式:
subplot(m,n,p)
- subplot() 函数将一个图像展示窗口分为m行n列个子区域
- 这些子图像按 自上而下,自左而右 进行编号
- p:表示这些编号的索引
- 并选择子图像p来接受当前所有画图命令
- 例如,命令subplot(2,3,4)将会创建6个子图像,而且subplot 4是当前子图像
EXAMPLE
x=0:0.1*pi:2*pi;
subplot(2,2,1)
plot(x,sin(x),'-*');
itle('sin(x)');
subplot(2,2,2)
plot(x,cos(x),'--o');
title('cos(x)');
subplot(2,2,3)
plot(x,sin(2*x),'-.*');
title('sin(2x)');
subplot(2,2,4);
plot(x,cos(3*x),':d')
title('cos(3x)')
RESULT