0% found this document useful (0 votes)
85 views

Dexp 8

The document describes designing digital FIR filters in MATLAB using windowing techniques. It discusses windowing techniques like Hamming and Kaiser windows. It provides the theory and steps for the FIR filter design process and implements the designed filters on a 4-tone test sequence to visualize the frequency response.

Uploaded by

raneraji123
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)
85 views

Dexp 8

The document describes designing digital FIR filters in MATLAB using windowing techniques. It discusses windowing techniques like Hamming and Kaiser windows. It provides the theory and steps for the FIR filter design process and implements the designed filters on a 4-tone test sequence to visualize the frequency response.

Uploaded by

raneraji123
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/ 5

EXPERIMENT 8

AIM - Write MATLAB program to design digital FIR filter employing


windowing techniques -
1. Hamming Window
2. Kaiser Window

THEORY - The design process of the FIR filter comprises two main phases:
1. The filter order is determined initially, followed by the computation of
coefficients.
2. Kaiser's approximate formula is utilized to estimate the filter order N.

Here are the steps delineated for developing MATLAB code to executethis
design:
1. Generate sampled sinusoids across a range of frequencies. Calculate
samples for a 4 - tone input signal.
2. Apply any windowing technique to design the FIR filter.
3. Visualize the frequency response, including both amplitude and phase.
Implement the designed filter onto the 4-tone test sequence.

IN LAB
wp=0.5*pi;
ws=0.6*pi;
delp=0.1;
dels=0.1;
fs=8000;
hn1=myFilter(wp,ws,delp,dels,0,0);
f1=figure;
freqz(hn1,1,1024,fs);
subtitle("LPF using rectangular window");
hn2=myFilter(wp,ws,delp,dels,0,1);
f2=figure;
freqz(hn2,1,1024,fs);
subtitle("HPF using rectangular window");
hn3=myFilter(wp,ws,delp,dels,1,0);
f3=figure;
freqz(hn3,1,1024,fs);
subtitle("LPF using Blackman window");
hn4=myFilter(wp,ws,delp,dels,1,1);
f4=figure;
freqz(hn4,1,1024,fs);
subtitle("HPF using Blackman window");
function hn = myFilter(wp, ws, delp, dels, wndow, hpf)
wc=(wp+ws)/2;
wt=abs(wp-ws);
del=min(delp,dels);

MAHAK SALECHA 22102210 A7


A=-20*log10(del);
if wndow==0 % use rectangular window for wndow = 0
N=ceil(4*pi/wt);
if mod(N,2) == 0
N= N+1;
end
wn=rectwin(N);
else% use blackman window for wndow ~= 0
N=ceil(12*pi/wt);
if mod(N,2) == 0
N= N+1;
end
wn = blackman(N);
end
T=(N-1)/2;
n=0:N-1;
if hpf==0 % for low pass filter
hn=(sin(wc*(n-T))/(pi*(n-T)))*wn;
else % for high pass filter when hpf ~=0
h= ((sin(pi*(n-(N/2))))/(pi*(n-(N/2))))-((sin(wc*(n-(N/2))))/(pi*(n-(N/2))));
hn=h*wn;
end
end

MAHAK SALECHA 22102210 A7


POST LAB
% example 1
wp1= 0.4 * pi;
ws1= 0.6 * pi;
delp1= 0.01;
dels1= 0.001;
hn1=filterKaiser(wp1,ws1,delp1,dels1,1,0);
f1=figure;
freqz(hn1);
subtitle("Example 1 with LPF using Kaiser window");
% postlab
wp2= 0.5*pi;
ws2= 0.6*pi;
delp2= 0.1;
dels2= 0.1;
fs=8000;
hn2=filterKaiser(wp2,ws2,delp2,dels2,1,0);
f2=figure;
freqz(hn2,1,1024,fs);
subtitle("LPF using kaiser window");
f3=figure;
hn3=filterKaiser(wp2,ws2,delp2,dels2,0,0);
freqz(hn3,1,1024,fs);
subtitle("LPF using hamming window");
f4=figure;
hn4=filterKaiser(wp2,ws2,delp2,dels2,1,1);
freqz(hn4,1,1024,fs);
subtitle("HPF using kaiser window");
f5=figure;
hn5=filterKaiser(wp2,ws2,delp2,dels2,0,1);
freqz(hn5,1,1024,fs);
subtitle("HPF using hamming window");
function hn = filterKaiser(wp, ws, delp, dels, wndow, hpf)
wc=(wp+ws)/2;
wt=abs(wp-ws);
del=min(delp,dels);
A=-20*log10(del);
if wndow==1 % use kaiser window for wndow = 1
if A>50
beta=0.1102 * (A-8.7);
elseif A>=21 && A<=50
beta=0.5842*((A-21)^0.4) + 0.07886*(A-21);
else
beta=0;
end
M=ceil((A-8)/(2.285*wt));
if mod(M,2) ~= 0
M= M+1;
end
N=M+1;
wn=kaiser(N,beta);
else% use hamming window for wndow ~= 1
N=ceil(8*pi/wt);
if mod(N,2) == 0
N= N+1;
end
wn = hamming(N);
end
MAHAK SALECHA 22102210 A7
T=(N-1)/2;
n=0:N-1;
if hpf==0 % for low pass filter
hn=(sin(wc*(n-T))/(pi*(n-T)))*wn;
else % for high pass filter when hpf ~=0
h= ((sin(pi*(n-(N/2))))/(pi*(n-(N/2))))-((sin(wc*(n-(N/2))))/(pi*(n-(N/2))));
hn=h*wn;
end
end

Result :FIR filter design was implemented in MATLAB using windowing technique.

Learning Outcomes: FIR filter design using windowing technique was implemented and studied in
MATLAB using various types of windows such as Rectangular, Blackmann, Kaiser, Hamming
windows.
MAHAK SALECHA 22102210 A7
MAHAK SALECHA 22102210 A7

You might also like