舉例
示例1:
在matlab的命令窗口中輸入doc subplot或者help subplot即可獲得該函數的幫助信息。
在MATLAB的命令窗口依次輸入以下命令:(>>不用輸入)
>> t=0:0.001:1;
>> y1=sin(10*t);
>> y2=sin(15*t);
>> subplot(211)
>> plot(t,y1)
>> subplot(212)
>> plot(t,y2)
運行結果見右圖。也可以将上述命令寫成一個程序段:
function subplot_sample1()
close all
figure
grid on
t=0:0.001:1;
y1=sin(10*t);
y2=sin(15*t);
subplot(211)
plot(t,y1)
subplot(212)
plot(t,y2)
示例2:
function subplot_sample1()
close all
figure
grid on
t=0:0.001:1;
subplot(2,2,1)
plot(t,sin(10*t))
subplot(2,2,2)
plot(t,cos(10*t))
subplot(2,2,3)
plot(t,tan(10*t))
subplot(2,2,4)
plot(t,cot(10*t))
示例3:
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])



















