Вы находитесь на странице: 1из 8

LOYOLA - ICAM

COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

Ex.No – 6 Design of FIR filters (LPF/HPF/BPF/BSF) and demonstrates the


Date: filtering operation

AIM:
To write the MATLAB program to design FIR filter using various window functions.

APPARATUS REQUIRED:
MATLAB , PC

ALGORITHM:
1. Start the program
2. Get the stop band frequency, pass band frequency, stop band ripple, pass band
ripple and samplingfrequency
3. Give the design specification for all filters
4. obtain the design frequency response of all filters
5. stop the program

THEORY:
A discrete time filter produces a discrete time output sequence, y(n) for discrete time input
sequence, x(n).digital filters i.e FIR depending on the form of unit pulse response of the
system. Here the sequence is of finite duration. The system with impulse response is as
follows:
h(n)=2, In I≤ 4
=0, otherwise
As the above has only a finite number of non-zero terms, it is an FIR system. FIR system has
exact linear phase and it is stable.

PROGRAM:

1.LOW PASS FILTER USING RECTANGULAR WINDOW

clc
closeall
clearall
N= input('Enter the value')
fc=input('Enter the cut offfreq')
fsamp=input('enter the samp frequency')
n=0:N-1
a=(N-1)/2;
b=0.000001
wc=2*pi*fc/fsamp;
h=(sin((n-a+b)*wc))./((n-a+b)*pi)
w=rectwin(N)
ha=w.*h'
f=0:0.01:pi
H=freqz(ha,1,f)
plot(f,H)
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

2.HIGH PASS FILTER USING HAMMING

clc
closeall
clearall
N= input('Enter the value')
fc=input('Entr the freq')
fs=input('Entr the samp.freq')
b=0.00000001
a=((N-1)/2);
wc=(2*pi*fc)/fs;
n=0:1:N-1;
h=(((sin ((n-a+b)*pi))-(sin((n-a+b)*wc)))./((n-a+b)*pi))
w= hamming(N)
f=0:0.01:pi
ha=w.*h'
H=freqz(ha,1,f)
plot(f,abs(H))
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

3.BAND PASS FILTER USING HANNING


clc
closeall
clearall
N= input('Enter the value')
fc1=input('Enter freq1')
fc2=input('Enter freq2')
fsamp=input('enter the sampfreq')
b=0.0001
a=(N-1)/2
wc1=(2*pi*fc1/fsamp)
wc2=(2*pi*fc2/fsamp)
n=0:1:N-1;
h=(sin((n-a+b)*wc2))-(sin((n-a+b)*wc1))./((n-a+b)*pi)
w= hann(N)
f=0:0.0001:pi
ha=w.*h'
H=freqz(ha,1,f)
plot(f,abs(H))
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)

4.BAND REJECT FILTER USING BLACKMAN


clc;
N= input('Enter the value')
fc1=input('Enter the freq')
fc2=input('Enter the freq')
fs=input('Enter the freq')
a=((N-1)/2)
b=0.000001
wc1=(2*pi*fc1)/fs
wc2=(2*pi*fc2)/fs
n=0:1:N-1;
h=(sin((n-a+b)*pi)-sin((n-a+b)*wc2)+sin((n-a+b)*wc1))./((n-a+b)*pi)
w=blackman(N)
d=h.*w'
f=0:0.001:pi;
H=freqz(d,1,f)
H1=abs(H)
plot(f,H1)
RESULT:
Thus, the LPF, HPF, BPF and BSF FIR filters were designed using various window functions
and their corresponding graphs are plotted.

Вам также может понравиться