布莱克曼窗:
切比雪夫窗:
Q7.22 程序如下:
clear;
Fp = 2*10^3; Fs = 2.5*10^3; FT = 10*10^3; Rp = 0.005; Rs = 0.005;
N = kaiord(Fp,Fs,Rp,Rs,FT) Wp = 2*Fp/FT; Ws = 2*Fs/FT; F = [0 Wp Ws 1]; A = [1 1 0 0]; h = firpm(N,F,A);
disp('Numerator Coefficients are ' ); disp(h);
[g, w] = gain(h,[1]); figure(1);
plot(w/pi,g);grid;
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)); 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('\\omega /\\pi' ); ylabel('Unwrapped Phase (rad)' ); title('Unwrapped Phase Response' );
低通滤波器系数:
0.0028 -0.0022 -0.0046 -0.0006 0.0053 0.0019 -0.0073 -0.0058 0.0079 0.0106 -0.0069 -0.0170 0.0032 0.0243 0.0045 -0.0319 -0.0182 0.0390 0.0422 -0.0448 -0.0924 0.0486 0.3136 0.4501 0.3136 0.0486 -0.0924 -0.0448 0.0422 0.0390 -0.0182 -0.0319 0.0045 0.0243 0.0032 -0.0170 -0.0069 0.0106 0.0079 -0.0058 -0.0073 0.0019 0.0053 -0.0006 -0.0046 -0.0022 0.0028 增益和相位响应:
从图中可以看出此时的滤波器不满足指标。欲满足指标,应调节N=47.
Q7.23 用凯泽窗设计一个有限冲激响应低通滤波器。
程序:
clear;
Wp = 0.31; Ws = 0.41;
Wn = Wp + (Ws-Wp)/2; As = 50;
Ds = 10^(-As/20); Dp = Ds; if As > 21
N = ceil((As-7.95)*2/(14.36*(abs(Wp-Ws)))+1) else
N = ceil(0.9222*2/abs(Wp-Ws)+1) end
if As > 50
BTA = 0.1102*(As-8.7); elseif As >= 21
BTA = 0.5842*(As-21)^0.4+0.07886*(As-21); else