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 default
FIGURE 6.63
Filter’s plots of Example 6.13.
4
[Impulse sequence h(n)] versus n
2
0
0510
time n n
15
Amplitude^2
4
6
[coeff. a1(n)] versus n
10
5
0
0 2 46
Amplitude
5
10
01
12
Real part
Imaginary part
zero-pole plot
1
0.5
0.5
1
1
0
20
10
0
10
20
30
4 2024
W
H1(W) versus W
Amplitude
time index n Index n