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

📄 fir_design_win1.m

📁 经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助
💻 M
字号:
% Name:FIR_design_win1.m
clear,close all;
wp=input('Type in the passband edge frequency (in Radian) wp=');
ws=input('Type in the passband edge frequency (in Radian) ws=');
deltaw=input('Type in the width of the transition band =');
wc=(wp+ws)/2;
L=ceil(8*pi/(ws-wp));
if L/2==ceil(L/2);
    L=L+1;
else
    L=L;
end
a=(L-1)/2;
n=0:L-1;
%w=u(n)-u(n-L);%Rectangle window, 
w=0.5*(1-cos(2*pi*n/(L-1))).*(u(n)-u(n-L)); %Hanning window
h=(wc/pi)*sin(wc*(n-a+eps))./(wc*(n-a+eps)).*w;
%=======================================================================
N=2000;
H=fft(h,N);
H=H/max(abs(H));           
W=0:2*pi/N:2*pi-2*pi/N;
%=======================================================================
subplot(222)
plot(W/pi,abs(H)),title('The magnitude response of the FIR filter')
axis([0,1,0,max(abs(H))]),grid on;
%=========================================================
subplot(223)
plot(W/pi,angle(H))
axis([0,1,-pi,pi]),grid on;
title('The phase response of the FIR filter'),xlabel('Frequency (*pi)')
%======================================================
subplot(224)
plot(W/pi,20*log10(abs(H)));
axis([0,1,-100,0]),grid on;
title('The frequency response in dB'),
xlabel('Frequency (*pi)')
%======================================================
subplot(221)
stem(n,h,'.'),
axis([0,L-1,min(h),max(h)]),grid on;
title('The impulse response of the FIR filter')
xlabel('Index n')
%=================================================

⌨️ 快捷键说明

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