1、数字信号处理实验7 Laboratory Exercise 7DIGITAL FILTER DESIGN7.1 DESIGN OF IIR FILTERSProject 7.1 Estimation of IIR Filter OrderAnswers:Q7.1 The normalized passband edge angular frequency Wp is -0.2 The normalized stopband edge angular frequency Ws is -0.4 The desired passband ripple Rp is -0.5dB The desired
2、 stopband ripple Rs is -40dB (1) Using these values and buttord we get the lowest order for a Butterworth lowpass filter to be - 8 The corresponding normalized passband edge frequency Wn is - 0.2469 or 0.2469pi (2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev lowpas
3、s filter to be -5 The corresponding normalized passband edge frequency Wn is - 0.2000 (3) Using these values and cheb2ord we get the lowest order for a Type 2 Chebyshev lowpass filter to be -5N, Wn = cheb2ord(0.2,0.4,0.5,40). The corresponding normalized passband edge frequency Wn is - 0.4000 (4) Us
4、ing these values and ellipord we get the lowest order for an elliptic lowpass filter to be 4N, Wn = ellipord(0.2,0.4,0.5,40). From the above results we observe that the Elliptic filter has the lowest order meeting the specifications.Q7.2 The normalized passband edge angular frequency Wp is - 0.6000
5、The normalized stopband edge angular frequency Ws is - 0.3429 The desired passband ripple Rp is -1dB The desired stopband ripple Rs is -50dB(1) Using these values and buttord we get the lowest order for a Butterworth highpass filter to be -8N, Wn = buttord(Wp,Ws,Rp,Rs). The corresponding normalized
6、passband edge frequency Wn is - 0.5647(2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev highpass filter to be 5N,Wn = cheb1ord(Wp,Ws,Rp,Rs). The corresponding normalized passband edge frequency Wn is - 0.6000(3) Using these values and cheb2ord we get the lowest order
7、 for a Type 2 Chebyshev highpass filter to be -5N,Wn = cheb2ord(Wp,Ws,Rp,Rs). The corresponding normalized passband edge frequency Wn is 0.3429(4) Using these values and ellipord we get the lowest order for an elliptic highpass filter to be -4N,Wn = ellipord(Wp,Ws,Rp,Rs).The corresponding normalized
8、 passband edge frequency Wn is Wn = 0.6000, From the above results we observe that the Elliptic filter has the lowest order meeting the specifications.Project 7.2 IIR Filter Design A copy of Program P7_1 is given below:%程序p7.1%巴特沃斯带阻滤波器的设计ws=0.4 0.6;wp=0.3 0.7;rp=0.4;rs=50;%估计滤波器的阶数N1,wn1=buttord(wp
9、,ws,rp,rs);%设计滤波器num,den=butter(N1,wn1,stop);%显示传输函数disp(分子系数是);disp(num);disp(分母系数是);disp(den);%计算增益响应g,w=gain(num,den);%绘制增益响应plot(w/pi,g);gridaxis(0 1 -60 5);xlabel(omega/pi);ylabel(增益,dB);title(巴特沃斯带阻滤波器的设计);Answers:Q7.5 The coefficients of the Butterworth bandstop transfer function generated by
10、 running Program P7_1 are as follows:分子系数是 Columns 1 through 6 0.0330 0.0000 0.2972 0.0000 1.1889 0.0000 Columns 7 through 12 2.7741 0.0000 4.1611 0.0001 4.1611 0.0000 Columns 13 through 18 2.7741 0.0000 1.1889 0.0000 0.2972 0.0000 Column 19 0.0330分母系数是 Columns 1 through 6 1.0000 0.0000 2.6621 0.000
11、0 4.1451 0.0001 Columns 7 through 12 4.1273 0.0001 2.8977 0.0000 1.4381 0.0000 Columns 13 through 18 0.5027 0.0000 0.1178 0.0000 0.0167 0.0000 Column 19 0.0011 The exact expression for the transfer function is The gain response of the filter as designed is given below: From the plot we conclude that
12、 the design 符合the specifications. The plot of the unwrapped phase response and the group delay response of this filter is given below:Here is the program to find and plot the unwrapped phase response and group delay:% 程序 Q7_5B% 巴特沃斯帯阻滤波器的设计% Plot the unwrapped phase and the group delay.Ws = 0.4 0.6;
13、 Wp = 0.2 0.8; Rp = 0.4; Rs = 50;% 估计滤波器节数N1, Wn1 = buttord(Wp, Ws, Rp, Rs);% 设计滤波器num,den = butter(N1,Wn1,stop);%显示传输函数,绘制不卷绕相位wp = 0:pi/1023:pi;wg = 0:pi/511:pi;Hz = freqz(num,den,wp);Phase = unwrap(angle(Hz);figure(1);plot(wp/pi,Phase);grid;% axis(0 1 a b);xlabel(omega /pi); ylabel(Unwrapped Phas
14、e (rad);title(Unwrapped Phase Response of a Butterworth Bandstop Filter);% 全延时GR = grpdelay(num,den,wg);figure(2);plot(wg/pi,GR);grid;%axis(0 1 a b);xlabel(omega /pi); ylabel(Group Delay (sec);title(Group Delay of a Butterworth Bandstop Filter);Project 7.4 Estimation of FIR Filter OrderAnswers:Q7.13
15、 The estimated order of a linear-phase lowpass FIR filter with the following specifications: p = 2 kHz, s = 2.5 kHz, p = 0.005, s = 0.005, and FT = 10 kHz obtained using kaiord is - The purpose of the command ceil is - To round the estimated order up to the next largest integer; the order has to be
16、integer, so if the formula returns a fraction it needs to be rounded up to the next whole number. The purpose of the command nargin is -To detect if kaiord has been called with fourarguments or with five. If five, its assumed that all the frequencies are analog and thatthe last argument is the sampl
17、ing frequency. If four, then the sampling frequencydefaults to 2, implying that the other frequency arguments are in units of cycles per sample.Project 7.5 FIR Filter DesignAnswers:Q7.20 The MATLAB program to design and plot the gain and phase responses of a linear-phase FIR filter using fir1 is sho
18、wn below. The filter order is estimated using kaiserord. The output data are the filter coefficients. % 程序Q7_20% 线性相位FIR低通滤波器的设计% 满足Q7.13的参数% 写出分子系数% 传输函数% - 增益响应% - 相位响应% - 绘制未卷绕相位响应%clear;Fp = 2*103;Fs = 2.5*103;FT = 10*103;Rp = 0.005;Rs = 0.005;%估计阶数N = kaiord(Fp,Fs,Rp,Rs,FT)Wp = 2*Fp/FT; % 规划角频率
19、Ws = 2*Fs/FT; Wn = Wp + (Ws - Wp)/2;h = fir1(N,Wn);disp(Numerator Coefficients are );disp(h);g, w = gain(h,1); figure(1);plot(w/pi,g);grid;%axis(0 1 -60 5);xlabel(omega /pi); ylabel(Gain in dB);title(Gain Response);% 频率响应w2 = 0:pi/511:pi;Hz = freqz(h,1,w2);MagH = abs(Hz);T1 = 1.005*ones(1,length(w2)
20、;T2 = 0.995*ones(1,length(w2);T3 = 0.005*ones(1,length(w2);figure(4);plot(w2/pi,MagH,w2/pi,T1,w2/pi,T2,w2/pi,T3);grid;% 相位figure(2);Phase = angle(Hz);plot(w2/pi,Phase);grid;xlabel(omega /pi); ylabel(Phase (rad);title(Phase Response);figure(3);UPhase = unwrap(Phase);plot(w2/pi,UPhase);grid;xlabel(ome
21、ga /pi); ylabel(Unwrapped Phase (rad);title(Unwrapped Phase Response); The coefficients of the lowpass filter corresponding to the specifications given in Question 7.20 are as shown below 0.0010 -0.0004 -0.0015 0.0000 0.0024 0.0010 -0.0038 -0.0032 0.00490.0071 -0.0050 -0.0128 0.0026 0.0202 0.0038 -0
22、.0284 -0.0166 0.03660.0404 -0.0436 -0.0909 0.0483 0.3129 0.4498 0.3129 0.0483 -0.0909-0.0436 0.0404 0.0366 -0.0166 -0.0284 0.0038 0.0202 0.0026 -0.0128-0.0050 0.0071 0.0049 -0.0032 -0.0038 0.0010 0.0024 0.0000 -0.0015-0.0004 0.0010 The generated gain and phase responses are given below: From the gai
23、n plot we observe that the filter as designed _DOES NOT_ meet the specifications.AS SHOWN in the two detail plots above, with N=46, neither the passband spec at wp= 0.4 (normalized frequency) nor the stopband spec at ws = 0.5 (normalized frequency) are met. So this design DOES NOT meet the spec.The
24、filter order that meets the specifications is N=66 Q7.23 The MATLAB program to design and plot the gain and phase responses of a linear-phase FIR filter using fir1 and kaiser is shown below. The filter order N is estimated using Eq. (7.37) and the parameter is computed using Eq. (7.36). The output d
25、ata are the filter coefficients. % 程序 Q7_23% 使用凯泽共识设计FIR低通滤波器% - 增益响应%clear;% 参数满足Q7.23.Wp = 0.31;Ws = 0.41;Wn = Wp + (Ws-Wp)/2;As = 50;Ds = 10(-As/20);Dp = Ds; if As 21N = ceil(As-7.95)*2/(14.36*(abs(Wp-Ws)+1)elseN = ceil(0.9222*2/abs(Wp-Ws)+1)end% (7.36) 计算Bif As 50BTA = 0.1102*(As-8.7);elseif As
26、= 21BTA = 0.5842*(As-21)0.4+0.07886*(As-21);elseBTA = 0;endWin = kaiser(N+1,BTA);h = fir1(N,Wn,Win);% 分子系数disp(Numerator Coefficients are );disp(h);%增益响应g, w = gain(h,1);figure(1);plot(w/pi,g);grid;axis(0 1 -80 5);xlabel(omega /pi); ylabel(Gain in dB);title(Gain Response);%频率响应w2 = 0:pi/511:pi;Hz =
27、freqz(h,1,w2);figure(2);Phase = angle(Hz);plot(w2/pi,Phase);grid;xlabel(omega /pi); ylabel(Phase (rad);title(Phase Response);figure(3);UPhase = unwrap(Phase);plot(w2/pi,UPhase);grid;xlabel(omega /pi); ylabel(Unwrapped Phase (rad);title(Unwrapped Phase Response); The coefficients of the lowpass filte
28、r corresponding to the specifications given in Question 7.23 are as shown below 0.0003 0.0008 0.0003 -0.0011 -0.0017 0.0000 0.0026 0.0027 -0.0010 -0.0049-0.0035 0.0033 0.0080 0.0034 -0.0074 -0.0119 -0.0018 0.0140 0.0161 -0.0027-0.0241 -0.0201 0.0127 0.0406 0.0236 -0.0354 -0.0754 -0.0258 0.1214 0.287
29、10.3597 0.2871 0.1214 -0.0258 -0.0754 -0.0354 0.0236 0.0406 0.0127 -0.0201-0.0241 -0.0027 0.0161 0.0140 -0.0018 -0.0119 -0.0074 0.0034 0.0080 0.0033-0.0035 -0.0049 -0.0010 0.0027 0.0026 0.0000 -0.0017 -0.0011 0.0003 0.00080.0003 From the gain plot we observe that the filter as designed _DOES_ meet the specifications. The filter order that meets the specifications is - N=60.The generated gain and phase responses are given below:
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1