Analog and Digital Filters 639
MATLAB Solution
% Script file: filter _ wind
format long
hnk = fir1(64,.4,kaiser(65,3.5));
[h1,w1] = freqz(hnk,1,256);
magk = 20*log10(abs(h1));
subplot(3,2,1)
plot(w1,magk)
title(‘Filter using kaiser win.’)
ylabel(‘gain in db’)
subplot(3,2,2)
hnhan = fir1(64,.4,hanning(65));
[h2,w2] = freqz(hnhan,1,256);
maghan = 20*log10(abs(h2));
plot(w2,maghan)
title(‘Filter using hanning win.’)
ylabel(‘gain in db’)
subplot(3,2,3)
hnbla = fir1(64,.4,blackman(65));
[h3,w3] = freqz(hnbla,1,256);
magblac=20*log10(abs(h3));
plot(w3,magblac)
title(‘Filter using blackman win.’)
ylabel(‘gain in db’)
subplot(3,2,4)
% hamming window is the defaultFIGURE 6.63
Filter’s plots of Example 6.13.4[Impulse sequence h(n)] versus n2
00510time n n15Amplitude^2
4
6[coeff. a1(n)] versus n
10500 2 46Amplitude
5 100112Real partImaginary partzero-pole plot
10.50.5 1
102010
0 10 20
30
4 2024
WH1(W) versus WAmplitudetime index n Index n