0% found this document useful (0 votes)
2 views6 pages

DSP Ex9

The document outlines an experiment to design FIR filters (Low Pass and High Pass) using windowing techniques in MATLAB, specifically employing rectangular, Hamming, and Kaiser windows. It includes the aim, theory, program code, output, analysis of each window method, precautions, results, and applications of FIR filters. The analysis highlights the strengths and limitations of each windowing technique in filter design.

Uploaded by

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

DSP Ex9

The document outlines an experiment to design FIR filters (Low Pass and High Pass) using windowing techniques in MATLAB, specifically employing rectangular, Hamming, and Kaiser windows. It includes the aim, theory, program code, output, analysis of each window method, precautions, results, and applications of FIR filters. The analysis highlights the strengths and limitations of each windowing technique in filter design.

Uploaded by

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

EXPERIMENT- 9

TITLE OF EXPERIMENT:
Design FIR filter (Low Pass Filter /High Pass Filter) using windowing
technique.
i. Using rectangular window
ii. Using hamming window
iii. Using kaiser window

1. AIM:
To write a program in MATLAB to design FIR filter (Low Pass Filter
/High Pass Filter) using windowing technique.
i. Using rectangular window
ii. Using hamming window
iii. Using kaiser window
2. SOFTWARE USED: MATLAB

3. THEORY:
A finite impulse response (FIR) filter is designed using various methods.
One of those methos is designing using windows. In this method, desired
impulse response is obtained from desired frequency response by inverse
Fourier transform. This desired impulse response (which is infinite) is passed
through certain window to get finite length. Some of the window techniques are
as shown:

HAMMING WINDOW:
The equation of hamming window is given as follows:
2𝛱𝑛
𝜔 𝑛 = 0.54 − 0.46 cos
𝑁−1
The window sequence and frequency response are as shown:
KAISER WINDOW:
The equation of kaiser window is given as follows:

I0 𝛽 𝑁−1
𝑤𝐾 𝑁 = I0 𝛼 𝑖𝑓 𝑛 ≤
2
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Where,
α = adjustable parameter i.e., side lobe level can be controlled w.r.t the main lobe
peak
2𝜋
β = α [1-( 𝑁−1 )2 ]1/2
2
∝ 1 𝑥 𝑘
I0(x) = 1 + ∑𝑘=1 𝑘! 2 (⸪ Modified zeroth order Bessel function)
The window sequence and frequency response are as shown:

RECTANGLE WINDOW:
The equation of rectangle window is given as follows:

1 𝑖𝑓 0 ≤ 𝑛 ≤ 𝑁 − 1
𝑤𝑅 𝑁 =
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

The window sequence and frequency response are as shown:


4. PROGRAM CODE:
Rectangular window:

% Taking parameters
n=input('Enter the order of the filter:');
fp = input('Enter the passband frequency :');
fs = input('Enter the stopband frequency :');
f = input('Enter the sampling frequency :');
wp = 2*fp/f; % Normalized pass band frequency
ws = 2*fs/f; % Normalized stop band frequency
y = boxcar(n+1); % Rectangular window sequence

% Code for low-pass filter


b = fir1(n,wp,y);% FIR filter function
[h,o]= freqz(b,1,256);%This is used to calculate the filter frequency response
m = 20*log10(abs(h));% magnitude in decibles
subplot(2,2,1);
plot(o/pi,m);
title('Magnitude Response of LPF');
ylabel('Gain in dB ---->');
xlabel('Normalized Frequency ---->');
grid on;

% Code for high-pass filter


b = fir1(n,wp,'high',y);% FIR high pass filter function
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));% magnitude in decibles
subplot(2,2,2);
plot(o/pi,m);
title('Magnitude Response of HPF');
ylabel('Gain in dB ---->');
xlabel('Normalized Frequency ---->');
grid on;

Hamming window:

% Taking parameters
n=input('Enter the order of the filter:');
fp = input('Enter the passband frequency :');
fs = input('Enter the stopband frequency :');
f = input('Enter the sampling frequency :');
wp = 2*fp/f;% Normalised pass band Frequency
ws = 2*fs/f;% Normalised stop band Frequency
y = hamming(n+1);% Hamming window sequence
%Code for low-pass filter
b = fir1(n,wp,y);% FIR filter function
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));% Magnitude in decibles
subplot(2,2,1);
plot(o/pi,m);
title('Magnitude Response of LPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');
grid on;

% Code for high-pass filter


b = fir1(n,wp,'high',y);% FIR high pass filter
[h,o] = freqz(b,1,256);
m = 20*log10(abs(h));% Magnitude in decibles
subplot(2,2,2);
plot(o/pi,m);
title('Magnitude Response of HPF');
ylabel('Gain in dB ---->');
xlabel('Normalised Frequency ---->');

Kaiser window:

% Taking parameters
fc=input('enter cutoff frequency:');
N=input('enter N-endpoint: ');
wc=fc*pi;
b=fir1(N,wc/pi,kaiser(N+1,8.5));%filter using kaiser window beta=8.5
w=0:.01:pi;
h=freqz(b,1,w);
subplot(2,2,1);
plot(w/pi,20*log(abs(h)));
title('kasier beta=8.5');
subplot(2,2,2);
b=fir1(N,wc/pi,kaiser(N+1,0.5));%filter using kaiser window beta=0.5
w=0:.01:pi;
h=freqz(b,1,w);
plot(w/pi,20*log(abs(h)));
title('kasier beta=0.5');

5. OUTPUT:

Rectangular Window:
Enter the order of the filter:2
Enter the passband frequency :200
Enter the stopband frequency :900
Enter the sampling frequency :2000
Hamming Window:
Enter the order of the filter:2
Enter the passband frequency :100
Enter the stopband frequency :800
Enter the sampling frequency :1000

Kaiser Window:
enter cutoff frequency:0.5
enter N-endpoint: 25

6. OUTPUT PLOT:

Rectangular Window:

Hamming Window:
Kaiser Window:

7. ANALYSIS:
Rectangular Window:
The rectangular window method offers simplicity and ease of
implementation, its high side lobes and poor frequency selectivity limit its
utility in applications where precise frequency response control and minimal
interference with adjacent frequencies are crucial.
Hamming Window:
In the Hamming window method, the ideal impulse response is multiplied
by a Hamming window function in the time domain. The Hamming window is
characterized by its ability to balance between the main lobe width and the side
lobe levels in the frequency domain
Kaiser Window:
The Kaiser window method stands out for its ability to provide precise
control over the frequency response of FIR filters. Its adaptability to various
specifications and applications makes it a powerful tool.By carefully
considering the shape factor β and understanding the trade-offs, designers can
harness the advantages of the Kaiser window method to create FIR filters
tailored to meet specific requirements in critical applications.

8. PRECAUTIONS:
 Add comments within the code to clarify complex DSP operations. 
 Ensure proper scaling and units for signals and parameters to maintain
accuracy
9. RESULT:
Written a program in MATLAB to design FIR filter using different windowing
technique.
10. APPLICATIONS:
1. Audio processing
2. Image processing
3. Telecommunication
4. Biomedical signal processing

You might also like