代码:
M = 45; As = 60;
n = [0:1:M-1];
beta = 0.1102*(As - 8.7)
%beta = 0.1102*(As - 8.7) + 0.3
w_kai = (kaiser(M, beta))'; wc1 = pi/3; wc2 = 2*pi/3;
hd = ideal_lp(wc1, M) + ideal_lp(pi, M) - ideal_lp(wc2, M);
h = hd .* w_kai;
[db, mag, pha, grd, w] = freqz_m(h, [1]);
%Plot
figure('NumberTitle', 'off', 'Name', 'Exameple 7.11')
set(gcf,'Color','white');
subplot(2,2,1); stem(n, hd); axis([0 M-1 -0.2 0.8]); grid on;
xlabel('n'); ylabel('hd(n)'); title('Ideal Impulse Response');
subplot(2,2,2); stem(n, w_kai); axis([0 M-1 0 1.1]); grid on;
xlabel('n'); ylabel('w(n)'); title('Kaiser Window');
subplot(2,2,3); stem(n, h); axis([0 M-1 -0.2 0.8]); grid on;
xlabel('n'); ylabel('h(n)'); title('Actual Impulse Response');
subplot(2,2,4); plot(w/pi, db); axis([0 1 -80 10]); grid on;
xlabel('frequency in pi units'); ylabel('Decibels'); title('Magnitude Response in dB');
运行结果:
参数β =5.6533,最小的阻带衰减小于60dB。很明显,我们增加β 就能使得衰减达到60dB,此时β =5.9533。
将上面代码的第2个β 公式前面注释去掉,再次运行,结果如下:
此时满足设计要求。