Demo entry 6646358

m

   

Submitted by WuChaozheng on Oct 16, 2017 at 13:06
Language: Matlab. Code size: 1.1 kB.

%窗长16
%矩形窗
n=0:15;
x=cos(n*pi/10)+sin(n*pi/6)+cos(2*n*pi/5);
X11=fft(x,256);     %补零至256
w=2*pi*(0:255)/256-pi;  %归一化频率范围
figure
subplot(2,1,1)
stem(w,abs(fftshift(X11)))
xlabel('频率');ylabel('幅度')
title('窗长16 矩形窗')
%汉明窗
h1=hamming(16)';    %窗长16的汉明窗
x12=x.*h1;
X12=fft(x12,256);
subplot(2,1,2)
stem(w,abs(fftshift(X12)))
xlabel('频率');ylabel('幅度')
title('窗长16 汉明窗')

%窗长64
%矩形窗
n=0:63;
x=cos(n*pi/10)+sin(n*pi/6)+cos(2*n*pi/5);
X21=fft(x,256);
figure
subplot(2,1,1)
stem(abs(fftshift(X21)))
xlabel('频率');ylabel('幅度')
title('窗长64 矩形窗')
%汉明窗
h2=hamming(64)';    %窗长64的汉明窗
x22=x.*h2;
X22=fft(x22,256);
subplot(2,1,2)
stem(w,abs(fftshift(X22)))
xlabel('频率');ylabel('幅度')
title('窗长64 汉明窗')

%窗长128
%矩形窗
n=0:127;
x=cos(n*pi/10)+sin(n*pi/6)+cos(2*n*pi/5);
X31=fft(x,256);
figure
subplot(2,1,1)
stem(w,abs(fftshift(X31)))
xlabel('频率');ylabel('幅度')
title('窗长128 矩形窗')
%汉明窗
h3=hamming(128)';   %窗长128的汉明窗
x32=x.*h3;
X32=fft(x32,256);
subplot(2,1,2)
stem(w,abs(fftshift(X32)))
xlabel('频率');ylabel('幅度')
title('窗长128 汉明窗')

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).