PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 641


Example 6.15

Create the script fi le multiban that returns the realization of a digital multiband nor-
malized fi lter with the specs indicated by the sketch shown in Figure 6.65, using the
following functions:
a. fi r2 of order 50, with a Bartlett window (FIR)
b. remez (FIR) of order 50
c. yulewalk digital IIR of order 15
MATLAB Solution
% Script File: multiban
w = [0 .1 .2 .3 .4 .5 .6 .7 .8 1];
mag = [0 0 1 1 0 0 1 1 0 0];
hnfir = fir2(50,w,mag,bartlett(51));
[h1, w1] = freqz(hnfir,1,256);
subplot (3,1,1)
plot (w1/pi, abs(h1))
ylabel (‘gain‘)
title (‘Multiban filter using fir2 (with bartlett window)’)
xlabel(‘frequency W (in rad)’)
subplot (3,1,2)
hnrem = remez(50,w,mag);
[h2, w2] = freqz (hnrem,1,256);
plot (w2/pi, abs(h2))
ylabel (‘gain‘)
title (‘Multiban filter using remez’)
xlabel(‘frequency W (in rad)’)
subplot(3,1,3)
[num,den] = yulewalk(15,w,mag);
[hiir,w] = freqz(num,den,256);
plot(w/(pi),abs(hiir))
ylabel (‘gain’)
title (‘Multiban filter using yulewalk’)
xlabel(‘frequency W (in rad)’)
The script fi le multiban is executed and the results are as follows (Figure 6.66):
>> multiban

FIGURE 6.65
Filter’s specs of Example 6.15.

H(W)

0

W (rad.)

1

.2 .4 .6 .8 1.0
Free download pdf