Udhay 8
Udhay 8
the Pass band cut off frequency:'); fs=input('enter the Stop band cut off frequency :'); f=input('sampling frequency'); ws=(2*fs/f); wp=(2*fp/f); num=20*log10(sqrt(rp*rs))-13; Den=(14.6*(fs-fp))/f; n=ceil(num/Den); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end; y=hamming(n1); %y=hanning(n1); %y=blackman(n1); %y=bartlett(n1); %y=boxcar(n1); b=fir1(n,wp,y); [h,a]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(m); title('low pass filter'); ylabel('gain in db'); xlabel('normalised frequency'); b=fir1(n,wp,'high',y); [h,a]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2); plot(m); title('high pass filter'); ylabel('gain in db'); xlabel('normalised frequency'); wn=[wp,ws]; b=fir1(n,wn,y); [h,a]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3); plot(m); title('band pass filter'); ylabel('gain in db'); xlabel('normalised frequency'); b=fir1(n,wn,'stop',y); [h,a]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(m); title('band stop filter'); ylabel('gain in db'); xlabel('normalised frequency');
output(hamming window): enter the Pass band enter the stop band enter the Pass band enter the Stop band sampling frequency3 ripple:10 ripple:20 cut off frequency:0.4 cut off frequency :0.6
low pass filter 0 -20 -40 -60 -80 -100 gain in db gain in db 10 0 -10 -20 -30
300
300
20 0 gain in db -20 -40 -60 -80 gain in db 0 100 200 normalised frequency 300
1 0 -1 -2 -3 -4
300