YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Fir Filter

EX NO: FIR FILTER REG NO:

DATE:

LOW PASS FILTER

RECTANGULAR

clear all;clc;close;N=11;Wc=%pi/2;l=(N-1)/2;for n=1:N if(n==l+1) hd(n)=Wc/%pi; else hd(n) =sin(Wc*((n-1)-l))/(((n-1)-l)*%pi); endend//Rectangular Windowfor n = 1:N W(n) = 1;end//Windowing Filter Coefficientsh = hd.*W;disp('Filter Coefficients are')[hzm,fr]=frmag(h,256);hzm_dB = 20*log10(hzm)./max(hzm);plot(fr,hzm_dB)xlabel('Normalized Digital Frequency W');ylabel('Magnitude in dB');title('Frequency Response 0f FIR LPF using Rectangular window M=7')

Page 2: Fir Filter

HANNING AND HAMMING WINDOW LOWPASS FILTER

clear all;clc;close;N=11;Wc=%pi/2;l=(N-1)/2;for n=1:N h_hann_11(n) = 0.5-0.5*cos(2*%pi*(n-1)/(N-1)) h_hamm_11(n) = 0.54-0.46*cos(2*%pi*(n-1)/(N-1))end[h_hann_11_N,fr]=frmag(h_hann_11,512);h_hann_11_N = 20*log10(h_hann_11_N./max(h_hann_11_N));scf()plot2d(fr,h_hann_11_N,2);xlabel('Normalized Digital Frequency W');

Page 3: Fir Filter

ylabel('Magnitude in dB');title('Frequency Response 0f hanning window Filter length M =11')[h_hamm_11_N,fr]=frmag(h_hamm_11,512);h_hamm_11_N= 20*log10(h_hamm_11_N./max(h_hamm_11_N));scf()plot2d(fr,h_hamm_11_N,2);xlabel('Normalized Digital Frequency W');ylabel('Magnitude in dB');title('Frequency Response of hamming window Filter length M =11')

Page 4: Fir Filter

BARLETT AND BLACKMAN WINDOW LOWPASS FILTER

clear all;clc;close;N=11;for n = 1:N h_bart_11(n) = 1-((2*(n-1)-((N-1)/2))/(N-1)) h_black_11(n) = 0.42-0.5*cos(2*%pi*(n-1)/(N-1))+0.08*cos(4*%pi*(n-1)/(N-1))end [h_bart_11_N,fr]=frmag(h_bart_11,512);h_bart_11_N = 20*log10(h_bart_11_N./max(h_bart_11_N));scf()plot2d(fr,h_bart_11_N,2);xlabel('Normalized Digital Frequency W');ylabel('Magnitude in dB');

Page 5: Fir Filter

title('Frequency Response 0f barlett window Filter length M =11')[h_black_11_N,fr]=frmag(h_black_11,512);h_black_11_N= 20*log10(h_black_11_N./max(h_black_11_N));scf()plot2d(fr,h_black_11_N,2);xlabel('Normalized Digital Frequency W');ylabel('Magnitude in dB');title('Frequency Response of blackman window Filter length M =11')

Page 6: Fir Filter

HIGH PASS FILTER

clc;clf;close();close();close();wc=0.75*%pi;N=25;alpha=(N-1)/2;eps=0.001;n=0:1:N-1;hd=(sin(%pi*(n-alpha+eps))-sin(wc*(n-alpha+eps)))./(%pi*(n-alpha+eps));win_1=window('re',N);hn=hd.*win_1;w=0:0.01:%pi;k=length(w);[h r]=frmag(hn,1,k);plot(w/%pi,abs(h));win_2=window('hn',N);hn1=hd.*win_2;w=0:0.01:%pi;

Page 7: Fir Filter

k=length(w);[h3 r]=frmag(hn1,1,k);scf();plot(w/%pi,abs(h3));win_3=window('hm',N);hn2=hd.*win_3;w=0:0.01:%pi;k=length(w);[h2 r]=frmag(hn2,1,k);scf();plot(w/%pi,abs(h2));win_4=window('ch',N,[0.01 -9]);hn3=hd.*win_4;w=0:0.01:%pi;k=length(w);[h4 r]=frmag(hn3,1,k);scf();plot(w/%pi,abs(h4));win_5=window('kr',N,3);hn5=hd.*win_5;w=0:0.01:%pi;k=length(w);[h5 r]=frmag(hn5,1,k);scf();plot(w/%pi,abs(h5));

Page 8: Fir Filter

output of rectangular window:

output of hanning window:

Page 9: Fir Filter

output of hamming window:

output of chebyshev window:

Page 10: Fir Filter

output of keiser window:

BAND PASS FILTER:

clc;clf;close();close();close();close();wc=0.1*%pi;wc1=0.75*%pi;N=25;alpha=(N-1)/2;eps=0.001;n=0:1:N-1;hd=(sin(wc1*(n-alpha+eps))-sin(wc*(n-alpha+eps)))./(%pi*(n-alpha+eps));win_1=window('re',N);hn=hd.*win_1;w=0:0.01:%pi;k=length(w);[h r]=frmag(hn,1,k);plot(w/%pi,abs(h));win_2=window('hn',N);disp(win_2);

Page 11: Fir Filter

hn1=hd.*win_2;w=0:0.01:%pi;k=length(w);[h3 r]=frmag(hn1,k);scf();plot(w/%pi,abs(h3));win_3=window('hm',N);disp(win_3);hn2=hd.*win_3;w=0:0.01:%pi;k=length(w);[h2 r]=frmag(hn2,1,k);scf();plot(w/%pi,abs(h2));win_4=window('ch',N,[0.01 -9]);hn3=hd.*win_4;w=0:0.01:%pi;k=length(w);[h4 r]=frmag(hn3,1,k);scf();plot(w/%pi,abs(h4));win_5=window('kr',N,3);hn5=hd.*win_5;w=0:0.01:%pi;k=length(w);[h5 r]=frmag(hn5,1,k);scf();plot(w/%pi,abs(h5));

output of rectangular window:

Page 12: Fir Filter

output of hanning window

output of hamming window:

Page 13: Fir Filter

output of chebyshev window:

output of keiser window:

Page 14: Fir Filter

BAND STOP FILTER:

clc;clf;close();close();close();wc=0.25*%pi;wc1=0.75*%pi;N=25;alpha=(N-1)/2;eps=0.001;n=0:1:N-1;hd=(sin(wc1*(n-alpha+eps))-sin(wc*(n-alpha+eps)))./(%pi*(n-alpha+eps));win_1=window('re',N);hn=hd.*win_1;w=0:0.01:%pi;k=length(w);[h r]=frmag(hn,1,k);plot(w/%pi,abs(h));win_2=window('hn',N);hn1=hd.*win_2;w=0:0.01:%pi;k=length(w);[h3 r]=frmag(hn1,1,k);scf();plot(w/%pi,abs(h3));win_3=window('hm',N);hn2=hd.*win_3;w=0:0.01:%pi;k=length(w);[h2 r]=frmag(hn2,1,k);scf();plot(w/%pi,abs(h2));win_4=window('ch',N,[0.01 -9]);hn3=hd.*win_4;w=0:0.01:%pi;k=length(w);[h4 r]=frmag(hn3,1,k);scf();plot(w/%pi,abs(h4));win_5=window('kr',N,3);hn5=hd.*win_5;w=0:0.01:%pi;k=length(w);[h5 r]=frmag(hn5,1,k);

Page 15: Fir Filter

scf();plot(w/%pi,abs(h5));

output of rectangular window:

output of hanning window:

Page 16: Fir Filter

output of hamming window:

output of chebyshev filter:

Page 17: Fir Filter

output of keiser window:


Related Documents