EE 451

Low-pass Filter Design Example using a Kaiser Window

fpass = 2.0e3;
fstop = 2.5e3;
Apass = 0.1;
Astop = 60;
fs = 48e3;

fc = (fpass+fstop)/2.0;
wc = 2*pi*fc/fs;
df = fstop - fpass;

delta_pass = (10^(Apass/20)-1)/(10^(Apass/20)+1);
delta_stop = 10^(-Astop/20);
delta = min(delta_pass,delta_stop);

A = -20*log10(delta);

alpha = .1101*(A-8.7);
D = (A-7.95)/14.36;
M = D*fs/df;
M = ceil(M);
if (rem(M,2)==1) 
	M = M+1;
end 
N = M+1;

n = 0:M;


kw = kaiser(N,alpha);

h = kw'.*sin(wc*(n-M/2))./(pi*(n-M/2));
h(M/2+1) = wc/pi;

w = 0:pi/1000:pi;
H = freqz(h,1,w);

subplot(221)
plot(n,h);
axis([0 M -0.05 0.1]);
title('h(n)')

subplot(222)
plot(w*fs*1e-3/(2*pi),20*log10(abs(H)));
axis([0 24 -90 10])
title('H(w) in dB')
xlabel('f (kHz)')

subplot(223)
plot(w*fs*1e-3/(2*pi),20*log10(abs(H)));
axis([2 3  -90 10])
grid
title('H(w) in dB')
xlabel('f (kHz)')

subplot(224)
plot(w*fs*1e-3/(2*pi),20*log10(abs(H)));
axis([1.5 2.5 -.1 .1])
grid
title('H(w) in dB')
xlabel('f (kHz)')