⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hamming.m

📁 经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助
💻 M
字号:
% Name:Hamming.m
clear
L=input('Type in the length N=');
n=0:L-1;
w=(0.54-0.46*cos(2*pi*n/(L-1))).*(u(n)-u(n-L));
x=0.3*sin(0.3*pi*(n-ceil((L-1)/2)+eps))./(0.3*pi*(n-ceil((L-1)/2)+eps)).*w;
%==========================================================================
N=1024;
H1=fft(w,N);
H2=fliplr(H1);
H=[H2(1:1023),H1];
H=H/max(abs(H));
F1=fft(x,N);
F2=fliplr(F1);
F=[F2(1:1023),F1];
F=F/max(abs(F));           
W=-2*pi+2*pi/N:2*pi/N:2*pi-2*pi/N;
%=======================================================================
figure(1)
subplot(221);
plot(W/pi,abs(F)),title('The magnitude response of FIR filter')
axis([-1,1,0,max(abs(F))]);grid on
%=========================================================
subplot(222)
plot(W/pi,abs(H));grid on
axis([-1,1,0,max(abs(H))])
title('The frequency response of the Hamming window'),
%======================================================
subplot(224)
plot(W/pi,20*log10(abs(H)/abs(H1(1))));grid on
axis([0,1,-100,0])
title('The frequency response in dB'),
xlabel('Frequency (*pi)')
%======================================================
subplot(223)
plot(W/pi,20*log10(abs(F)));grid on
axis([0,1,-100,0])
title('The frequency response in dB'),
xlabel('Frequency (*pi)')
%======================================================
figure(2)
subplot(221)
stem(n,w,'.');grid on
title('The Hamming window')
xlabel('Index n')
axis([0,L-1,min(w),max(w)])
%=================================================
subplot(222)
stem(n,x,'.');grid on
title('The truncated impulse response')
xlabel('Index n')
axis([0,L-1,min(x),max(x)])
%==================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -