PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Analog and Digital Filters 625


Example 6.7

Create the script fi le analog_digital that returns the following:
a. The third-order normalized analog low-pass Butterworth fi lter’s magnitude and
phase plots of H(w).
b. Use lp2lp to transform the normalized fi lter of part (a) to an analog LPF with wc = 3
rad/s, and obtain the magnitude and phase plots of H(w).
c. With a sampling rate of T = 0.3 obtain the numerator and denominator coeffi cients
of the discrete IIR transfer function H(z) fi lter for wc = 3 rad/s of part (b).
d. Obtain its zero/pole plot of H(z) of part (c) and verify that the system implementa-
tion is stable.
e. Obtain its zero/pole plot of H(s) of part (b) and verify that the system is stable and
the three analog poles map into the three discrete poles of H(z).
f. Obtain the magnitude and phase plots of the discrete transfer function H(z).

MATLAB Solution
% Script file: analog _ digital
[z,p,k] = buttap(3); % create an analog normalized filter
[Pn,Qn]= zp2tf (z,p,k); % analog normalized transfer function
T=.3;Wc=3;
[Pa,Qa]=lp2lp(Pn,Qn,Wc);
w =-5:.1:5;
h = freqs(Pn,Qn,w);

figure(1)
subplot (1,2,1) % plot of normalized butt. LPF
plot (w, abs(h));
axis([-5 5 0 1.2]);
title (‘ Mag.analog norm. LPF’)
xlabel (‘w in rad/sec’)
ylabel (‘Magnitude’)
subplot (1,2,2)
plot(w,angle(h))
xlabel (‘w in rad/sec’)
ylabel (‘angle’)
title(‘Phase analog norm LPF’)

figure(2)
subplot (1,2,1) % plot of LPF, wc =3
h2 = freqs(Pa,Qa,w);
plot (w, abs(h2));
title (‘ Mag. of LPF with wc=3’)
xlabel (‘w in rad/sec’)
ylabel (‘magnitude ‘); axis([-5 5 0.2 1.1]);
subplot (1,2,2)
Free download pdf