资源描述:
《IIR和FIR滤波器的MATLAB设计.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、IIR和FIR滤波器的MATLAB设计2012301510047付维杰一、问题根据下列参数完成IIR和FIR数字滤波器设计通带范围300Hz~500Hz带内最大衰减Rp=-3dB阻带范围<250Hz&>550Hz带内最小衰减Rs=-40dB采样频率Fs=2000Hz要求:1、分别完成IIR和FIR滤波器的设计2、IIR设计不可使用butter、cheby1、cheby2和ellip这四个完全设计函数3、谈谈自己对两种滤波器设计的感受二、分析与建模在数字滤波器设计中,大致分为两种:一种是有限冲激响应滤波器,简称F
2、IR;另一种是无限冲激响应滤波器,简称IIR。对于IIR,设计流程为:确定滤波器阶数、设计模拟原型滤波器、频率变换、变换到数字滤波器。确定阶数常用到函数“butterord”、“cheb1ord”、“cheb2ord”等,模拟低通滤波器原型的设计常用到“buttap”、“cheb1ap”、“cheb2ap”,变换到带通用到函数“lp2bp”,最后完成到数字域通常用冲激函数不变法或者双线性变换法。当然还有完全设计函数“butter”、“cheb1”等,只需给定参数即生成对应的滤波器参数。对于FIR,常用的设计方法
3、是窗口法和最优等波动法。前者用到fir1和fir2这两个函数,后者用到remezord和remez函数,其对应的函数输入参量可以在MATLAB的HELP系统中查看或者仿照已有的设计例子。除了上述一步步确定滤波器的参数,MATLAB也可以同fdatool来直接设计滤波器,只需在交互界面给出滤波器的种类和参数即可。本次设计也用到了它。三、源代码1、巴特沃斯设计IIR(冲激函数不变法):%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Builddate:2014/12/28%%%%%B
4、uilder:2012301510047_付维杰%%%%%Usefunctionof"impinvar"%%%%%BUTTERWORTH%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Fs=2000;%freaquencyofsampleWp=[300*2*pi500*2*pi];%passingbandWs=[250*2*pi550*2*pi];%stopbandRp=3;%MaximunattenuationofpassingbandRs=40%Minimunattenuationof
5、stopband[n,Wn]=buttord(Wp,Ws,Rp,Rs,'s');%order[z,p,k]=buttap(n);%zero,peak,gainWo=sqrt(Wn(1)*Wn(2));%Centerfrequency[b,a]=zp2tf(z,p,k);%zerototransmitfunction[bt,at]=lp2bp(b,a,Wo,Wn(2)-Wn(1));%lowtoband[bz,az]=impinvar(bt,at,Fs);%impulseofinvariantfreqz(bz,a
6、z)2、巴特沃斯设计IIR(双线性变换法):%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Builddate:2014/12/28%%%%%Builder:2012301510047_付维杰%%%%%Usebilineartransformation%%%%%BUTTERWORTH%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Fs=2000;%frequencyofsampleWp=[tan(300*pi/Fs)*Fs*2tan(500*pi/Fs)*F
7、s*2];Ws=[tan(250*pi/Fs)*Fs*2tan(550*pi/Fs)*Fs*2];Rp=3;%MaximunattenuationofpassingbandRs=40%Minimunattenuationofstopband[n,Wn]=buttord(Wp,Ws,Rp,Rs,'s');%order[z,p,k]=buttap(n);%zero,peak,gainWo=sqrt(Wn(1)*Wn(2));%Centerfrequency[b,a]=zp2tf(z,p,k);%zerototran
8、smitfunction[bt,at]=lp2bp(b,a,Wo,Wn(2)-Wn(1));%lowtoband[bz,az]=bilinear(bt,at,Fs);%impulseofinvariantfreqz(bz,az)3、切比雪夫I型设计IIR:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Builddate:2014/12/28%%%%%B