Professional Documents
Culture Documents
Name:- Raghvendra
DIV:- TY-ELEX-B
Roll No:- 28
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