FIR FILTER USING DIFFERENT WINDOW MATLAB PROGRAM

FIR FILTER USING DIFFERENT WINDOW


 


 

f=input('Samplin rate in Hz, f=');

fp=input('pass band edge frequency in Hz=');

fs=input('stop band edge frequency in Hz=');

rp=input('pass band ripple in dB=');

rs=input('minimum stop band attenuation in dB=');

wp=2*fp/f;

ws=2*fs/f;

[N,wn]=cheb1ord(wp,ws,rp,rs);


 

%Hann window


 

Hw=hann(N+1);

B=fir1(N,wn,Hw);

[H,omega]=freqz(B,1,256);

gain=20*log(abs(H));

subplot(2,2,1);

plot(omega/pi,gain);

grid;

xlabel('omega/pi');

ylabel('Gain in dB');

title('FIR LPF using HANN window');


 

%Hamming window


 

Hw=hamming(N+1);

B=fir1(N,wn,Hw);

[H,omega]=freqz(B,1,256);

gain=20*log(abs(H));

subplot(2,2,2);

plot(omega/pi,gain);

grid;

xlabel('omega/pi');

ylabel('Gain in dB');

title('FIR LPF using HAMMING window');


 

%Rectangular window


 

Hw=rectwin(N+1);

B=fir1(N,wn,Hw);

[H,omega]=freqz(B,1,256);

gain=20*log(abs(H));

subplot(2,2,3);

plot(omega/pi,gain);

grid;

xlabel('omega/pi');

ylabel('Gain in dB');

title('FIR LPF using RECTANGULAR window');


 

%Triangular window


 

Hw=triang(N+1);

B=fir1(N,wn,Hw);

[H,omega]=freqz(B,1,256);

gain=20*log(abs(H));

subplot(2,2,4);

plot(omega/pi,gain);

grid;

xlabel('omega/pi');

ylabel('Gain in dB');

title('FIR LPF using TRIANGULAR window');


 


 


 


 


 


 


 


 

Observation:


 

Samplin rate in Hz,f=2000

pass band edge frequency in Hz=200

stop band edge frequency in Hz=300

pass band ripple in dB=6

minimum stop band attenuation in dB=30


 


 


 


 

0 comments: