You are on page 1of 2

FIR FILTER METHOD 1

%generate filter (low pass) coefficients for the given order & cutoff N=33,fc=15
0hz,fs=1000hz,hamming window
h=firl(33,150/(1000/2),hamming(34));
n=1:30;
f1=50;f2=300;f3=200;fs=1000;
x=[];
x1=sin(2*pi*n*f1/fs);
x2=sin(2*pi*n*f2/fs);
x3=sin(2*pi*n*f3/fs);
x=[x1 x2 x3];
subplot(2,1,1);
stem(x);
title('input');
y=filter(h,1,x);
subplot(2,1,2);
stem(y);
title('output');
RESULT:ONLY 50HZ IS PASSED, 300HZ & 200HZ CUTOFF
------------------FIR FILTER METHOD 1
%generate filter(low pass) co-efficients for the given order & cutoff N=33,fc=15
0hz,fs=1000hz,hamming window using CONV
h=firl(33,150/(1000/2),hamming(34));
n=1:30;
f1=50;f2=300;f3=200;fs=1000;
x=[];
x1=sin(2*pi*n*f1/fs);
x2=sin(2*pi*n*f2/fs);
x3=sin(2*pi*n*f3/fs);
x=[x1 x2 x3];
subplot(2,1,1);
stem(x);
title('input');
y=conv(h,x);
subplot(2,1,2);
stem(y);
title('output');
RESULT:FREQ BELOW 150HZ PASSED OTHERS CUTOFF
------------------FIR FILTER METHOD 1
%generate filter(band pass) coefficients for given order & cutoff N=33,200hz pas
sed(150-250),fs=1000hz,hamming window
w1=150/(1000/2);
w2=250/(1000/2);
wn=[w1 w2];
h=firl(33,wn,'bandpass',hamming(34));
n=1:30;
f1=50;f2=400;f3=200;fs=1000;
x=[];
x1=sin(2*pi*n*f1/fs);
x2=sin(2*pi*n*f2/fs);
x3=sin(2*pi*n*f3/fs);
x=[x1 x2 x3];
subplot(2,1,1);

stem(x);
title('input');
y=filter(h,1,x);
subplot(2,1,2);
stem(y);
title('output');
RESULT:ONLY FREQ B/W 150-250 ARE PASSED

You might also like