Q7.5 通过运行P7.1设计巴特沃兹带阻滤波器,写出所产生的传输函数的准确表达式。滤波器的指标是什么?使用MATLAB计算并绘制滤波器未畸变的相位相应及群延迟相应。 MATLAB程序为:
% Program P7_1
Ws = [0.4 0.6]; Wp = [0.2 0.8]; Rp = 0.4; Rs = 50; [N1, Wn1] = buttord(0.2, 0.4, 0.5, 40); [num,den] = butter(N1,Wn1,'stop');
disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response plot(w/pi,g);grid axis([0 1 -60 5]);
xlabel('\\omega /\\pi'); ylabel('Gain in dB');
title('Gain Response of a Butterworth Bandstop Filter');
得到:
Numerator Coefficients are Columns 1 through 9
0.0493 0.0000 0.2465 0.0000 0.4930 0.0000 0.4930 0.0000 0.2465 Columns 10 through 11 0.0 0.0493
Denominator Coefficients are Columns 1 through 9
1.0000 0.0000 -0.0850 0.0000 0.6360 0.0000 -0.0288 0.0000 0.0561 Columns 10 through 11 0.0000 -0.0008
因此表达式为:
0.0493+0.2465z-2 +0.4930z-4?0.4930z-6 ?0.2465z-8?0.0493z-10H (z)= -2-4-6-8-101-0.0850z +0.6360z-0.0288z ?0.0561z?0.0008z 指标为?P1=0.2?,?S1=0.4?,?S2=0.6?,?P2=0.8?,RP=0.4dB,RS=50dB
Q7.6 修改P7.1后来设计符合习题Q7.1所给指标的切比雪夫1型低通滤波器。写出产生的传输函数的准确表达式。使用MATLAB计算并绘制滤波器未畸变的相位相应及群延迟响应。 修改P7.1后的程序(切比雪夫1型低通滤波器):
% Program Q7_6
% Design spec as given in Q7.1. FT = 40*10^3; % sampling freq
Fp = 4*10^3; % analog passband edge freq Fs = 8*10^3; % analog stopband edge freq Rp = 0.5; % max passband ripple, dB Rs = 40; % min stopband attenuation, dB
% Convert spec to normalized digital frequencies omega_p = 2*pi*Fp/FT; Wp = 2*Fp/FT; % omega_p/pi omega_s = 2*pi*Fs/FT; Ws = 2*Fs/FT; % omega_s/pi % Estimate the Filter Order
[N, Wn] = cheb1ord(Wp, Ws, Rp, Rs); % Design the Filter
[num,den] = cheby1(N,Rp,Wn); % Display the transfer function
disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response figure(1);
plot(w/pi,g);grid; axis([0 1 -60 5]);
xlabel('\\omega /\\pi'); ylabel('Gain in dB');
title('Gain Response of a Type 1 Chebyshev Lowpass Filter'); % Find and plot the phase figure(2);
w2 = 0:pi/511:pi; Hz = freqz(num,den,w2); Phase = unwrap(angle(Hz)); plot(w2/pi,Phase);grid;
xlabel('\\omega /\\pi'); ylabel('Unwrapped Phase (rad)'); title('Unwrapped Phase Response of a Type 1 Chebyshev Lowpass Filter');
% Find and plot the group delay figure(3);
GR = grpdelay(num,den,w2); plot(w2/pi,GR);grid;
xlabel('\\omega /\\pi'); ylabel('Group Delay (sec)'); title('Group Delay of a Type 1 Chebyshev Lowpass Filter');
编写的MATLAB程序如下(计算未畸变的相位响应及群延迟响应):
% Program Q7_6
Ws = [0.4 0.6]; Wp = [0.2 0.8]; Rp = 0.4; Rs = 50; % Estimate the Filter Order
[N1, Wn1] = buttord(Wp, Ws, Rp, Rs); % Design the Filter
[num,den] = butter(N1,Wn1,'stop');
% Find the frequency response; find and plot unwrapped phase 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 Phase (rad)');
title('Unwrapped Phase Response of a Butterworth Bandstop Filter'); % Find and plot the group delay 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');
0-2-4Unwrapped Phase Response of a Butterworth Bandstop FilterUnwrapped Phase (rad)-6-8-10-12-14-16-18-2000.20.4? /?Group Delay of a Butterworth Bandstop Filter0.60.81
1098Group Delay (sec)76543200.20.4? /?0.60.81
Q7.9 使用sinc编写一个MATLAB程序,以产生截止频率在?C=0.4?处,长度分别为81,61,41,和21的四个零相位低通滤波器的冲激响应系数,然后计算并画出它们的幅度响应。使用冒号“:”运算符从长度为81的滤波器的冲激响应系数中抽出较短长度滤波器的冲激响应系数。在每一个滤波器的截止频率两边研究频率响应的摆动行为。波纹的数量与滤波器的长度有什么关系?最大波纹的高度与滤波器的长度有什么关系?将怎样修改上述程序以产生一个偶数长度的零相位低通滤波器的冲激响应系数?
(1)长度为81的零相位低通滤波器的冲激响应:
1.41.2Magnitude Response for Length=8110.8|H(ej?)|0.60.40.2000.20.4? /?0.60.81
(2)长度为61的零相位低通滤波器的冲激响应:
1.41.2Magnitude Response for Length=6110.8|H(ej?)|0.60.40.2000.20.4? /?0.60.81
(3)长度为41的零相位低通滤波器的冲激响应: