52 Exp 6
52 Exp 6
EXP.NO. : 06
FIR FILTER DESIGN AND ITS ANALYSIS WITH
DATE : 26/03/25 WINDOWING METHOD
AIM:
To design FIR filter and its analysis with the windowing method using MATLAB.
SOFTWAREREQUIRED:
MATLAB2023
PROGRAM:
LOW PASS FILTER:
%rectangular
N=11
wc=0.5
h=fir1(N,wc,'low',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hanning
h=fir1(N,wc,'low',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
IIYEAR/ECE-A DSPLAB
23ECR011
2
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hamming
h=fir1(N,wc,'low',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%blackman
h=fir1(N,wc,'low',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
OUTPUT:
%WITH N=152
%rectangular
N=152
wc=0.5
h=fir1(N,wc,'low',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("Low pass filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hanning
h=fir1(N,wc,'low',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("Low pass filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
%hamming
h=fir1(N,wc,'low',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
% blackman
h=fir1(N,wc,'low',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
OUTPUT:
IIYEAR/ECE-A DSPLAB
23ECR011
2
HIGH PASS FILTER:
PROGRAM:
%
rectangular
N=11+1
wc=0.5
h=fir1(N,wc,'high',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%hanning
h=fir1(N,wc,'high',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
% hamming
h=fir1(N,wc,'high',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
% blackman
h=fir1(N,wc,'high',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
OUTPUT:
%WITH N=152
%rectangular
N=152
wc=0.5
h=fir1(N,wc,'high',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
%hanning
h=fir1(N,wc,'high',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%hamming
h=fir1(N,wc,'high',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%blackman
h=fir1(N,wc,'high',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
title("High pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
OUTPUT:
% rectangular
N=11+1
wc=[0.25 0.5]
h=fir1(N,wc,'bandpass',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hanning
h=fir1(N,wc,'bandpass',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
%hamming
h=fir1(N,wc,'bandpass',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%blackman
h=fir1(N,wc,'bandpass',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
OUTPUT:
%WITH N=152
%rectangular
N=152
wc=[0.25 0.5]
h=fir1(N,wc,'bandpass',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
IIYEAR/ECE-A DSPLAB
23ECR011
plot(w,abs(H)) 2
title("Band pass filter ")
IIYEAR/ECE-A DSPLAB
23ECR011
2
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hanning
h=fir1(N,wc,'bandpass',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%hamming
h=fir1(N,wc,'bandpass',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%blackman
h=fir1(N,wc,'bandpass',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
title("Band pass filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
OUTPUT:
IIYEAR/ECE-A DSPLAB
23ECR011
2
%rectangular
N=11+1
wc=[0.25 0.5]
h=fir1(N,wc,'stop',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hanning
h=fir1(N,wc,'stop',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
%hamming
h=fir1(N,wc,'stop',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency (rad)")
ylabel("|H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
%blackman
h=fir1(N,wc,'stop',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
OUTPUT:
%WITH N=152
%rectangular
N=152
wc=[0.25 0.5]
h=fir1(N,wc,'stop',rectwin(N+1))
[H,w]=freqz(h,1)
subplot(2,2,1)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
IIYEAR/ECE-A DSPLAB
23ECR011
2
%hanning
h=fir1(N,wc,'stop',hann(N+1))
[H,w]=freqz(h,1)
subplot(2,2,2)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%hamming
h=fir1(N,wc,'stop',hamming(N+1))
[H,w]=freqz(h,1)
subplot(2,2,3)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency
(rad)") ylabel("|
H(e^jw)|")
%blackman
h=fir1(N,wc,'stop',blackman(N+1))
[H,w]=freqz(h,1)
subplot(2,2,4)
plot(w,abs(H))
title("Band stop filter ")
xlabel("frequency
(rad)") ylabel("|H(e^jw)|
IIYEAR/ECE-A DSPLAB
23ECR011
2
OUTPUT:
RESULT:
Thus, the FIR filter and its analysis with the windowing method using MATLAB was done successfully
IIYEAR/ECE-A DSPLAB