You are on page 1of 3

DSP Lab/MBT/Assignment5

Name:- Raghvendra
DIV:- TY-ELEX-B  
Roll No:- 28

Title: FIR Filter Design

Problem Statement: Design a lowpass FIR filter with 11


coefficients for the  following specifications:  
Passband frequency edge = 0.25 KHz and sampling

frequency = 1 KHz.  Use 1. rectangular Window  

 2. Hamming window in the design  

B = fir1(N, Wn, WIN) designs an Nth order FIR filter using the N+1
length vector  WIN to window the impulse response. If empty or
omitted, fir1 uses a Hamming  window of length N+1.  

Matlab Code:  

1. Hamming Window 
fc = 0.25; 
fs = 1; 
N = 10 
wc = 2*pi*fc/fs; 

% Hamming window 
b = fir1(N,wc/pi,hamming(N+1)); 
w = 0:0.01:pi; 
h = freqz(b,1,w); 
subplot(2,1,1); 
plot(w/pi,20*log10(abs(h))); 
xlabel('Frequency'); 
ylabel ('Magnitude'); 
title('Hamming Window');
subplot(2,1,2); 
plot(w/pi,phase(h)); 
xlabel('Frequency'); 
ylabel('Phase'); 
figure 
2. Rectangular Window 
b = fir1(N,wc/pi,boxcar(N+1)); 
w = 0:0.01:pi; 
h = freqz(b,1,w); 
subplot(2,1,1); 

plot(w/pi,20*log10(abs(h))); 
xlabel('Frequency'); 
ylabel ('Magnitude'); 
title('Rectangular Window'); 
subplot(2,1,2); 
plot(w/pi,phase(h)); 
xlabel('Frequency'); 
ylabel('Phase'); 
figure 

Results:  

1. Hamming Window
2. Rectangular Window 

You might also like