654
Practical MATLAB
® Applications for Engineers
FIGURE 6.78
Filter’s plot of part (c) of Example 6.20.
1.4
200
150
100
50
Ϫ50
Ϫ100
Ϫ150
Ϫ200
0
1.2
0.8
Magnitude
Angle in degrees
0.6
0.4
0.2
0
0
0.5
frequency W in rad
Mag. of BPF using remez/orderϭ8
Phase of BPF using remez/orderϭ8
1
0
0.5
frequency W in rad
1
1
For each of the fi lters obtain the magnitude and phase plots.
The solution is given by the script fi le review_FIR_LPF as follows:
MATLAB Solution
% Script file : review _ FIR _ LPF
% Design of FIR using remez
f = linspace(0,1,10);
mag = [ones(1,3) .707 zeros(1,6)];
Pz = remez(25,f,mag);
Qz =1;
Hremez = freqz(Pz,Qz);
omega = 0:1/512:511/512;
figure(1)
subplot(2,1,1)
plot(omega,abs(Hremez))
xlabel(‘frequency in rad’)
ylabel(‘magnitude’)
title(‘Mag./FIR using remez’)
grid on;
subplot(2,1,2)
plot(omega,unwrap(angle(Hremez)))
xlabel(‘frequency in rad’)
ylabel(‘phase’)
title(‘Phase/FIR using remez’)
grid on;
% Design of FIR using fir1/Hamming window
Pz1 = fir1(25,0.3);
win = hamming(26);
Pz1= Pz1.*win’;
Hfir1= freqz(Pz1,1);
CRC_47760_CH006.indd 654
CRC_47760_CH006.indd 654
7/23/2008 2:27:01 PM
7/23/2008 2:27:01 PM
Practical MATLAB
® Applications for Engineers
FIGURE 6.78
Filter’s plot of part (c) of Example 6.20.
1.4
200
150
100
50
Ϫ50
Ϫ100
Ϫ150
Ϫ200
0
1.2
0.8
Magnitude
Angle in degrees
0.6
0.4
0.2
0
0
0.5
frequency W in rad
Mag. of BPF using remez/orderϭ8
Phase of BPF using remez/orderϭ8
1
0
0.5
frequency W in rad
1
1
For each of the fi lters obtain the magnitude and phase plots.
The solution is given by the script fi le review_FIR_LPF as follows:
MATLAB Solution
% Script file : review _ FIR _ LPF
% Design of FIR using remez
f = linspace(0,1,10);
mag = [ones(1,3) .707 zeros(1,6)];
Pz = remez(25,f,mag);
Qz =1;
Hremez = freqz(Pz,Qz);
omega = 0:1/512:511/512;
figure(1)
subplot(2,1,1)
plot(omega,abs(Hremez))
xlabel(‘frequency in rad’)
ylabel(‘magnitude’)
title(‘Mag./FIR using remez’)
grid on;
subplot(2,1,2)
plot(omega,unwrap(angle(Hremez)))
xlabel(‘frequency in rad’)
ylabel(‘phase’)
title(‘Phase/FIR using remez’)
grid on;
% Design of FIR using fir1/Hamming window
Pz1 = fir1(25,0.3);
win = hamming(26);
Pz1= Pz1.*win’;
Hfir1= freqz(Pz1,1);
CRC_47760_CH006.indd 654
CRC_47760_CH006.indd 654
7/23/2008 2:27:01 PM
7/23/2008 2:27:01 PM
