PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 649


Example 6.19

Create the script fi le FIR_IIR that returns the magnitude plots of a 17th-order normal-
ized FIR fi lter by truncating a third-order IIR Butterworth digital fi lter with a cutoff
frequency at 0.25 rad.
Compare the plots of the 17th-order normalized FIR fi lter with the third-order IIR fi lter.
MATLAB Solution
% Script file: FIR _ IIR
% FIR from a third order normalized
% butterworth IIR FILTER with Wc=.25
[num,den] = butter(3,.25);
numad = [num zeros(1,30)];
divnumbyden = deconv(numad,den);
imp = dimpulse(num,den,30);
num9 = imp(1:19); % first 18 coefficients
% for the FIR implementation
h18 = freqz(numad,1);h = freqz(num,den);
W = 0:1/512:511/512;
plot(W,20*lo g10(a b s(h)),W,20*lo g10(a b s(h 18)))
ylabel(‘Magnitude in db’)
xlabel(‘W in rad’);
title(‘FIR IMPLEMENTATION FROM IIR’);
axis([0 1 -100 20]);grid on;
gtext(‘IIR FILTER’)
gtext(‘FIR FILTER’)

FIGURE 6.74
Phase plots of IIR normalized LP digital fi lter of order: 4, 6, 8, and 10 using the function yulewalk of Exa mple 6.18.

4

2

0
Angle

01 0.5

Order 4

 2

 4

4

2

0
Angle

01 0.5

Order 6

 2

 4

4

2

0
Angle

01 0.5

Order 8

W in rad W in rad

 2

 4

4

2

0
Angle

01 0.5

Order 10

 2

 4
Free download pdf