656 Practical MATLAB® Applications for Engineers
FIGURE 6.80
Twe n t y- fi fth-order normalized FIR/LPF using the MATLAB fi r1 function of Example 6.21.
0
0
1
magnitude0.5
1.5
0.1 0.2 0.3 0.4 0.5
Mag./FIR using fir1
frequency in rad
0.6 0.7 0.8 0.9 1
0
25
20
15
10
5
0
phase in rad.
0.1 0.2 0.3 0.4 0.5
Phase/FIR using fir1
frequency in rad
0.6 0.7 0.8 0.9 1
MATLAB Solution
% Script file: revisit _ analog _ filters
% part (a)
% normalize low pass filters: Butt. and Cheby.
[z1,p1,k1] = buttap (4);
[num1,den1] = zp2tf(z1,p1,k1);
w =0:.01:6;
figure(1)
subplot(2,2,1);
H1= freqs(num1,den1,w);
plot(w,abs(H1));
ylabel(‘magnitude’)
title(‘Butt. norm. LPF’)
subplot(2,2,2);
plot(w,angle(H1)*180/pi)
ylabel(‘phase (deg)’)
title(‘Butt. LPF’)
[z2,p2,k2] = cheb1ap(4,2); % type 1,with 2 db passband
[num2,den2] = zp2tf(z2,p2,k2);
H2 = freqs(num2,den2,w);
subplot(2,2,3);
plot(w,abs(H2))
ylabel(‘magnitude’)
title(‘Cheb. norm. LPF’)
xlabel(‘frequency (rad/sec)’)
subplot(2,2,4);
plot(w,angle(H2)*180/pi)
ylabel(‘phase (deg)’)
title(‘Cheb. LPF’)
xlabel(‘frequency (rad/sec)’)