PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 629


Example 6.8

Create the script fi le direc_butt_disig that solves Example 6.7 by directly obtaining the
magnitude and phase plots of the discrete transfer function H(z) (LPF third order, with
T = 0.3 and a cutoff frequency of wc = 3 rad/s).

% Script file : direc _ butt _ disig
n =3;
T=.03;wc=3;w =-5:.1:5;
wz = w*T;
[Pz,Qz] = butter(n,wc*T/pi);
[magz,phasez]=freqz(Pz,Qz,wz/pi);
subplot(1,2,1)
plot(wz,magz);
title(‘Mag. of digital LPF’);axis([-5 5 0.4 1.1]);
xlabel(‘w in rad’)
ylabel(‘magnitude’)
subplot(1,2,2)
plot(wz,phasez*180/pi);
title(‘Phase of digital LPF vs w’)
xlabel(‘w in rad’)
ylabel(‘phase in degrees’)

Back in the command window, the script fi le direc_butt_ disig is executed and the results
are shown as follows (Figure 6.58):

>> direc _ butt _ disig

FIGURE 6.57
Magnitude and phase plots of H(z) of Example 6.7.

Mag. of digital filter H(z )

1

0.9

0.8

magnitude0.7

0.6

0.5

1.1

0.4
 2  1012
W in rad

Phase of digital filter H(z )
30

20

10

 10

 20

 30
 2  1012
W in rad

0
degrees
Free download pdf