行业saas:MATLAB中subplot的用法

来源:百度文库 编辑:中财网 时间:2024/04/28 07:16:00

subplot(m,n,p)或者subplot(m n p)

subplot是将多个图画到一个平面上的工具。其中,m表示是图排成m行,n表示图排成n列,也就是整个figure中有n个图是排成一行的,一共m行,如果第一个数字是2就是表示2行图。p是指你现在要把曲线画到figure中哪个图上,最后一个如果是1表示是从左到右第一个位置。

下面是两个例子,可加深理解,

>> t=0:0.001:1;
>> y1=sin(10*t);
>> y2=sin(15*t);
>> subplot(211)
>> plot(t,y1)
>> subplot(212)
>> plot(t,y2)

x1=[1 2 3];x2=x1;x3=x2;x4=x1;
y1=[2 4 6];y2=2*y1;y3=3*y1;y4=4*y1;
subplot(2,2,1)
plot(x1,y1);
axis([0,20,0,20])
subplot(2,2,2)
plot(x2,y2);
axis([0,20,0,20])
subplot(2,2,3)
plot(x3,y3)
axis([0,20,0,20])
subplot(2,2,4)
plot(x4,y4)
axis([0,20,0,20])