Analog and Digital Filters
651
ylabel(‘Magnitude’)
title(‘Mag. of LPF using fir1/order=18’)
subplot(1,2,2)
plot(w1,angle(Hlp)*180/pi);grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of LPF using fir1/order=18’)
% FIR/BPF using fir1/part(b)
f = [.3 .6];
% passband region
coefbp = fir1(8,f,’noscale’) ;
% noscale, BP 8th. order filter
Hbp=freqz(coefbp,1);
figure(2)
subplot(1,2,1)
plot(w1,abs(Hbp));grid on;
xlabel(‘ frequency W in rad.’)
ylabel(‘Magnitude’)
title(‘Mag. of BPF using fir1/order=8’)
subplot(1,2,2)
plot(w1,angle(Hbp)*180/pi);grid on;
xlabel(‘ frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of BPF using fir1/order=8’)
%***********************************
%FIR/BPF using remez
freq = [0 .25 .3 .6 .65 1.0];
% specifies normalized freqs.
mag = [0 0 1 1 0 0];
error = [2.0 1.5 2.0];
% error weights per band
num = remez(8,freq,mag,error) ;
% 8th. order BPF
Hrem=freqz(num,1);
figure(3)
subplot(1,2,1)
plot(w1,abs(Hrem));grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Magnitude’)
title(‘Mag. of BPF using remez/order=8’)
subplot(1,2,2)
plot(w1,angle(Hrem)*180/pi);grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of BPF using remez/order=8’);
den=1;
disp(‘***********************************************’)
disp(‘
* * * * R E S U L T S * * * *
‘)
disp(‘***********************************************’)
disp(‘***********************************************’)
disp(‘ The coefficients of the FIR/LPF using fir1 are:’)
disp(coeflp)
tf(coeflp,1,-1)
disp(‘***********************************************’)
disp(‘ The coefficients of the FIR/BPF using fir1 are:’)
disp(coefbp)
CRC_47760_CH006.indd 651
CRC_47760_CH006.indd 651
7/23/2008 2:27:00 PM
7/23/2008 2:27:00 PM
651
ylabel(‘Magnitude’)
title(‘Mag. of LPF using fir1/order=18’)
subplot(1,2,2)
plot(w1,angle(Hlp)*180/pi);grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of LPF using fir1/order=18’)
% FIR/BPF using fir1/part(b)
f = [.3 .6];
% passband region
coefbp = fir1(8,f,’noscale’) ;
% noscale, BP 8th. order filter
Hbp=freqz(coefbp,1);
figure(2)
subplot(1,2,1)
plot(w1,abs(Hbp));grid on;
xlabel(‘ frequency W in rad.’)
ylabel(‘Magnitude’)
title(‘Mag. of BPF using fir1/order=8’)
subplot(1,2,2)
plot(w1,angle(Hbp)*180/pi);grid on;
xlabel(‘ frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of BPF using fir1/order=8’)
%***********************************
%FIR/BPF using remez
freq = [0 .25 .3 .6 .65 1.0];
% specifies normalized freqs.
mag = [0 0 1 1 0 0];
error = [2.0 1.5 2.0];
% error weights per band
num = remez(8,freq,mag,error) ;
% 8th. order BPF
Hrem=freqz(num,1);
figure(3)
subplot(1,2,1)
plot(w1,abs(Hrem));grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Magnitude’)
title(‘Mag. of BPF using remez/order=8’)
subplot(1,2,2)
plot(w1,angle(Hrem)*180/pi);grid on;
xlabel(‘frequency W in rad.’)
ylabel(‘Angle in degrees’)
title(‘Phase of BPF using remez/order=8’);
den=1;
disp(‘***********************************************’)
disp(‘
* * * * R E S U L T S * * * *
‘)
disp(‘***********************************************’)
disp(‘***********************************************’)
disp(‘ The coefficients of the FIR/LPF using fir1 are:’)
disp(coeflp)
tf(coeflp,1,-1)
disp(‘***********************************************’)
disp(‘ The coefficients of the FIR/BPF using fir1 are:’)
disp(coefbp)
CRC_47760_CH006.indd 651
CRC_47760_CH006.indd 651
7/23/2008 2:27:00 PM
7/23/2008 2:27:00 PM
