plot()用来绘制连续图像
stem()用来绘制散点图
subplot()设置子图的位置
Fs=64; T=1/Fs;
N=16;n=0:N-1;
nT = n*T;
x6n=cos(8*pi*nT)+cos(16*pi*nT)+cos(20*pi*nT)
X6k16=fft(x6n,16);
N=16;
f=2/N*(0:N-1);
figure(4);
xx6 = 0:0.02*pi/20:0.3*pi
yy6 = cos(8*pi*xx6)+cos(16*pi*xx6)+cos(20*pi*xx6)
subplot(2,2,1);
plot(xx6,yy6);
title('x_6(n)');xlabel('xx');ylabel('幅度');
subplot(2,2,2);stem(f,abs(X6k16),'.');
title('x_6(n) 16');xlabel('ω/π');ylabel('幅度');
N=32;n=0:N-1;
nT = n*T;
x6n=cos(8*pi*nT)+cos(16*pi*nT)+cos(20*pi*nT)
X6k32=fft(x6n,32);
N=32;
f=2/N*(0:N-1);
subplot(2,2,3);stem(f,abs(X6k32),'.');
title(' x_6(n) 32');xlabel('ω/π');ylabel('幅度');
N=64;n=0:N-1;
nT = n*T;
x6n=cos(8*pi*nT)+cos(16*pi*nT)+cos(20*pi*nT)
X6k64=fft(x6n,64);
N=64;
f=2/N*(0:N-1);
subplot(2,2,4);stem(f,abs(X6k64),'.');
title(' x_6(n) 64 ');xlabel('ω/π');ylabel('幅度');