Saturday 17 September 2011

Hamming windown

 FIR FILTER USING HAMMING WINDOW
clc; clear all; close all
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband freq');
fs=input('enter the stopband freq');
f=input('enter the sampling freq');
wp=2*fp/f;ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
    n1=n;
    n=n-1;
end
y=hamming(n1);
%LOW -PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
ylabel('gain in db-->');
xlabel('(a)normalised frequency-->');
title('LOW-PASS FILTER');
%BAND PASS FILTER
wn=[wp ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);plot(o/pi,m);
ylabel('gain in db-->');
xlabel('(c)normalised frequency-->');
title('BAND PASS FILTER');

0 comments:

Post a Comment