DSP Lab Exp9
DSP Lab Exp9
Experiment: 09
DESIGN FIR FILTER USING WINDOWING TECHNIQUE
Aim: To Design FIR filter (Low Pass Filter /High Pass Filter) using windowing technique.
Theory:
DSP Lab
DSP Lab
MATLAB Program:
1. Program for Low Pass FIR Filter Design Using Rectangular and Triangular Windows
Expected Input/Output:
Enter order of filter: 21
Enter pass band edge frequency: 500
Enter sampling frequency 5000
Expected Graphs:
-20
Magnitude in dB
-40
-60
-80
-100
-120
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency
DSP Lab
2. Program for High Pass FIR Filter Design Using Rectangular and Blackman Windows
% High Pass FIR Filter Design Using Windows
clc;
clear all;
N=input('Enter order of filter: ');
Fp=input('Enter pass band edge frequency: ');
Fs=input('Enter sampling frequency ');
Wp=2*pi*Fp/Fs;
b1=fir1(N,Wp,'high',boxcar(N+1)); %FIR Filter design using Rectangular window
b2=fir1(N,Wp,'high',blackman(N+1)); %FIR Filter design using Blackman window
[h,w]=freqz(b1,1); % obtain Frequency response for Rectangular window
plot(w/pi,20*log10(abs(h))); %Plot Frequency response for Rectangular window
hold on
[h,w]=freqz(b2,1); %obtain Frequency response for Blackman window
plot(w/pi,20*log10(abs(h)),'-g'); %Plot Frequency response for Blackman
window
xlabel('normalized frequency');
ylabel('Magnitude in dB');
title('High pass frequency response');
legend('Rectangular','Blackman');
hold off
Expected Input/Output:
Enter order of filter: 20
Enter pass band edge frequency: 500
Enter sampling frequency 5000
Expected Graphs:
High pass frequency response
20
Rectangular
0 Blackman
-20
-40
Magnitude in dB
-60
-80
-100
-120
-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency
Result:
Thus FIR filter for Low pass and High pass are designed using MATLAB
Exercise:
1. Write the MATLAB code for FIR filter Design for pass band and Stop band.