0% found this document useful (0 votes)
30 views3 pages

Fir Filter

This document compares the frequency response of a bandpass filter designed with different window functions. It designs a bandpass filter with center frequencies of 0.785 and 2.356 radians/sample using rectangular, hamming, hanning, and blackman windows. It then plots the magnitude response of each filter to show that blackman and hanning windows produce the smoothest response while rectangular has the highest ripple.

Uploaded by

s.reegan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Fir Filter

This document compares the frequency response of a bandpass filter designed with different window functions. It designs a bandpass filter with center frequencies of 0.785 and 2.356 radians/sample using rectangular, hamming, hanning, and blackman windows. It then plots the magnitude response of each filter to show that blackman and hanning windows produce the smoothest response while rectangular has the highest ripple.

Uploaded by

s.reegan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

%fir filter .....

bandpass filter
clc;
close all;
clear all;
wc1=0.785; %wc1=pi/4
wc2=2.356; %wc2=3pi/4
N=51; %no.of.taps
alpha=(N-1)/2;
eps=0.001;
n=0:1:N-1;
hd=(sin(wc2*(n-alpha+eps))-sin(wc1*(n-
alpha+eps)))./(pi*(n-alpha+eps));
%hd=(sin(3*pi*n/4)-sin(pi*n/4))/pi*n

%rectangular window
wr=rectwin(N);
hn=hd.*wr';
w=0:0.01:pi;
h=freqz(hn,1,w);
plot(w/pi,abs(h),'b');
hold on;

%hamming window
wh=hamming(N);
hn=hd.*wh';
w=0:0.01:pi;
h=freqz(hn,1,w);
plot(w/pi,abs(h),'r');
hold on;

%hanning window
wn=hanning(N);
hn=hd.*wn';
w=0:0.01:pi;
h=freqz(hn,1,w);
plot(w/pi,abs(h),'g');
hold on;

%blackman window
wn=blackman(N);
hn=hd.*wn';
w=0:0.01:pi;
h=freqz(hn,1,w);
plot(w/pi,abs(h),'m');
hold on;

leg=legend('rectangular','hamming','hanning','black
man');
set(leg,'interpreter','none');
title('response of bpf for various
windows...07ece52');
ylabel('magnitude');
xlabel('normalised frequency');
grid on;
OUTPUT:

response of bpf for various windows...07ece52


1.4
rectangular
hamming
1.2
hanning
blackman
1

0.8
magnitude

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalised frequency

You might also like