实验六IIR数字滤波器设计及应用一:实验目的加深理解IIR数字滤波器的特性,掌握IIR数字滤波器的设计原理与设计方法,以及IIR数字滤波器的应用。二:实验原理N阶IIR数字滤波器的系统函数为:iiNijjMjzazbzH101)(NNNNMMMMzazazazbzbzbb)1(111)1(11101IIR数字滤波器的设计主要通过成熟的模拟滤波器设计方法来实现:将数字滤波器设计指标转换为模拟滤波器设计指标,设计出相应的模拟滤波器H(s),再经过脉冲响应不变法或双线性变换法得到所需的IIR数字滤波器H(z)。IIR数字滤波器设计的重要环节是模拟原型低通滤波器的设计,主要包括Butterworth、Chebyshev和椭圆等滤波器。MATLAB信号处理工具箱中提供了IIR滤波器设计的函数。IIR滤波器阶数选择buttord-巴特沃斯(Butterworth)滤波器阶数选择。cheb1ord-切比雪夫(Chebyshev)I型滤波器阶数选择。cheb2ord-切比雪夫(Chebyshev)II型滤波器阶数选择。ellipord-椭圆(Elliptic)滤波器阶数选择。IIR滤波器设计butter-巴特沃斯(Butterworth)滤波器设计cheby1-切比雪夫(Chebyshev)I型滤波器设计cheby2-切比雪夫(Chebyshev)II型滤波器设计ellip-椭圆(Elliptic)滤波器设计maxflat-通用的巴特沃斯(Butterworth)低通滤波器设计yulewalk-Yule-Walker滤波器设计(直接数字滤波器设计法)1.Butterworth滤波器设计Butterworth滤波器是通带、阻带都单调衰减的滤波器。(1)调用buttord函数确定巴特沃斯滤波器的阶数,格式为[N,Wc]=buttord(Wp,Ws,Ap,As)输入参数:Ap,As为通带最大衰减和阻带最小衰减,以dB为单位。Wp,Ws为归一化通带截频和阻带截频,0Wp,Ws1。输出参数:N为滤波器的阶数;Wc为截频,0Wc1。(2)调用butter函数设计出巴特沃斯滤波器,格式为[b,a]=butter(N,Wc,options)输入参数:N和Wc是buttord函数返回的参数,含义见上。Options=’low’,’high’,’bandpass’,’stop’,分别对应低通、高通、带通、带阻,默认情况下为低通或带通。输出参数:b和a为设计出的IIR数字滤波器H(s)的分子多项式和分母多项式的系数矩阵。2.ChebyshevI型滤波器设计ChebyshevI型滤波器为通带纹波控制器:在通带呈现纹波特性,在阻带单调衰减。[N,Wc]=cheb1ord(Wp,Ws,Ap,As)[b,a]=cheby1(N,Ap,Wc,options)参数含义与butter中参数一致。2.ChebyshevII型滤波器设计ChebyshevII型滤波器为阻带纹波控制器:在阻带呈现纹波特性。[N,Wc]=cheb2ord(Wp,Ws,Ap,As)[b,a]=cheby2(N,As,Wc,options)3.椭圆滤波器设计椭圆滤波器在通阻带都呈现纹波特性。[N,Wc]=ellipord(Wp,Ws,Ap,As)[b,a]=ellip(N,Ap,As,Wc,options)三:实验内容1(1)[N,Wc]=buttord(0.250,0.677,3,60)[b,a]=butter(N,Wc)freqz(b,a);axis([0,1,-120,0]);gridontitle('巴特沃斯低通数字滤波器')(2)[N,Wc]=buttord(0.250,0.677,3,60)[b,a]=butter(N,Wc,'high')freqz(b,a);axis([0,1,-120,0]);gridontitle('巴特沃斯高通数字滤波器')(3)Wp=[0.250.67];Ws=[0.25-0.030.67+0.03];Rp=3;Rs=60;[N,Wc]=buttord(Wp,Ws,Rp,Rs)[b,a]=butter(N,Wc,'bandpass')freqz(b,a);axis([0,1,-120,0]);gridontitle('巴特沃斯带通数字滤波器')N=40Wc=0.24990.6701b=Columns1through90.00000-0.000000.00000-0.000000.0000Columns10through180-0.000000.00000-0.000000.00000Columns19through27-0.000100.00030-0.000700.00170-0.0037Columns28through3600.00720-0.012500.01950-0.02760Columns37through450.03530-0.040800.04290-0.040800.0353Columns46through540-0.027600.01950-0.012500.00720Columns55through63-0.003700.00170-0.000700.00030-0.0001Columns64through7200.00000-0.000000.00000-0.00000Columns73through810.00000-0.000000.00000-0.000000.0000a=1.0e+005*Columns1through90.0000-0.00010.0003-0.00110.0030-0.00740.0160-0.03180.0585Columns10through18-0.10080.1637-0.25190.3692-0.51740.6952-0.89801.1176-1.3427Columns19through271.5597-1.75421.9125-2.02342.0794-2.07732.0188-1.90981.7596Columns28through36-1.57981.3828-1.18030.9828-0.79850.6332-0.49020.3705-0.2734Columns37through450.1970-0.13860.0953-0.06390.0419-0.02680.0167-0.01020.0061Columns46through54-0.00350.0020-0.00110.0006-0.00030.0002-0.00010.0000-0.0000Columns55through630.0000-0.00000.0000-0.00000.0000-0.00000.0000-0.00000.0000Columns64through72-0.00000.0000-0.00000.0000-0.00000.0000-0.00000.0000-0.0000Columns73through810.0000-0.00000.0000-0.00000.0000-0.00000.0000-0.00000.0000(4)Wp=[0.250.67];Ws=[0.25-0.030.67+0.03];Rp=3;Rs=60;[N,Wc]=buttord(Wp,Ws,Rp,Rs)[b,a]=butter(N,Wc,'stop')freqz(b,a);axis([0,1,-120,0]);gridontitle('巴特沃斯带阻数字滤波器')N=40Wc=0.24990.6701b=1.0e+005*Columns1through70.0000-0.00000.0000-0.00000.0000-0.00000.0000Columns8through14-0.00000.0000-0.00000.0000-0.00000.0000-0.0000Columns15through210.0001-0.00010.0003-0.00070.0015-0.00290.0056Columns22through28-0.01020.0179-0.03050.0502-0.07980.1227-0.1828Columns29through350.2636-0.36860.4998-0.65760.8396-1.04091.2534Columns36through42-1.46601.6661-1.84011.9753-2.06102.0904-2.0610Columns43through491.9753-1.84011.6661-1.46601.2534-1.04090.8396Columns50through56-0.65760.4998-0.36860.2636-0.18280.1227-0.0798Columns57through630.0502-0.03050.0179-0.01020.0056-0.00290.0015Columns64through70-0.00070.0003-0.00010.0001-0.00000.0000-0.0000Columns71through770.0000-0.00000.0000-0.00000.0000-0.00000.0000Columns78through81-0.00000.0000-0.00000.0000a=1.0e+005*Columns1through70.0000-0.00010.0003-0.00110.0030-0.00740.0160Columns8through14-0.03180.0585-0.10080.1637-0.25190.3692-0.5174Columns15through210.6952-0.89801.1176-1.34271.5597-1.75421.9125Columns22through28-2.02342.0794-2.07732.0188-1.90981.7596-1.5798Columns29through351.3828-1.18030.9828-0.79850.6332-0.49020.3705Columns36through42-0.27340.1970-0.13860.0953-0.06390.0419-0.0268Columns43through490.0167-0.01020.0061-0.00350.0020-0.00110.0006Columns50through56-0.00030.0002-0.00010.0000-0.00000.0000-0.0000Columns57through630.0000-0.00000.0000-0.00000.0000-0.00000.0000Columns64through70-0.00000.0000-0.00000.0000-0.00000.0000-0.0000Columns71through770.0000-0.00000.0000-0.00000.0000-0.00000.0000Columns78through81-0.00000.0000-0.00000.00003(1)T0=204;N=205;T=1;k=0:T0;x=sin((2/8000)*770*pi*k)+sin((2/8000)*1209*pi*k);subplot(2,1,1);stem(k,x);title('时域波形');Xm=fft(x,N)/N;f=(-(N-1)/2:(N-1)/2)/N/T;subplot(2,1,2);stem(f,abs(fftshift(Xm)));title('频谱图');(2)[N,Wc]=buttord(0.1925,0.30225,3,60)[b,a]=butter(N,Wc)freqz(b,a);axis([0,1,-120,0]);gridontitle('巴特沃斯低通数字滤波