0% found this document useful (0 votes)
9 views15 pages

52 Exp 6

The document outlines the design and analysis of FIR filters using the windowing method in MATLAB, focusing on low pass, high pass, band pass, and band stop filters. It includes MATLAB code examples for each filter type with different windowing techniques such as rectangular, Hanning, Hamming, and Blackman. The results confirm the successful implementation of FIR filters and their analysis.

Uploaded by

akilanm.23ece
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views15 pages

52 Exp 6

The document outlines the design and analysis of FIR filters using the windowing method in MATLAB, focusing on low pass, high pass, band pass, and band stop filters. It includes MATLAB code examples for each filter type with different windowing techniques such as rectangular, Hanning, Hamming, and Blackman. The results confirm the successful implementation of FIR filters and their analysis.

Uploaded by

akilanm.23ece
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

23ECR011

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))

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)

IIYEAR/ECE-A DSPLAB
23ECR011
2

plot(w,abs(H))

title("Low pass filter ")

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))

title("Low pass filter ")

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))

title("Low pass filter ")

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))

title("Low pass filter ")

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))

title("Low pass filter ")

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:

BAND PASS FILTER:


PROGRAM:

% 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

BAND PASS FILTER:


PROGRAM:

%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

You might also like