Sunday, October 16, 2011

FIR KAISER WINDOW

%LPF
clc
clear
close all
samp=2000;
n=0:1/samp:1;
x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n);
ap=0.5;%ap=-20*log10(1-dp)
as=80;%as=-20*log10(ds)
dp=1-10^(-ap/20);
ds=10^(-as/20);
[N,W,bta,filtype] = kaiserord( [300 400], [1 0], [dp ds], samp );
w = window(@kaiser,N+1,bta);
figure
subplot 121, plot(1:N+1,w);
b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale');
[h,o]=freqz(b,1,256);
subplot 122, plot(o/pi, 20*log10(abs(h)));
y=filter(b,1,x);
figure
subplot 211, plot(abs(fft(x)));
subplot 212, plot(abs(fft(y)));



%HPF
clc
clear
close all
samp=2000;
n=0:1/samp:1;
x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n);
ap=0.5;%ap=-20*log10(1-dp)
as=80;%as=-20*log10(ds)
dp=1-10^(-ap/20);
ds=10^(-as/20);
[N,W,bta,filtype] = kaiserord( [300 400], [0 1], [ds dp], samp );
w = window(@kaiser,N+1,bta);
figure
subplot 121, plot(1:N+1,w);
b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale');
[h,o]=freqz(b,1,256);
subplot 122, plot(o/pi, 20*log10(abs(h)));
y=filter(b,1,x);
figure
subplot 211, plot(abs(fft(x)));
subplot 212, plot(abs(fft(y)));




%BPF
clc
clear
close all
samp=2000;
n=0:1/samp:1;
x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n);
ap=0.5;%ap=-20*log10(1-dp)
as=80;%as=-20*log10(ds)
dp=1-10^(-ap/20);
ds=10^(-as/20);
[N,W,bta,filtype] = kaiserord( [300 450 550 650 ], [0 1 0], [ds dp ds], samp );
w = window(@kaiser,N+1,bta);
figure
subplot 121, plot(1:N+1,w);
b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale');
[h,o]=freqz(b,1,256);
subplot 122, plot(o/pi, 20*log10(abs(h)));
y=filter(b,1,x);
figure
subplot 211, plot(abs(fft(x)));
subplot 212, plot(abs(fft(y)));



%BSF
clc
clear
close all
samp=2000;
n=0:1/samp:1;
x=cos(2*pi*100*n)+cos(2*pi*500*n)+cos(2*pi*700*n);
ap=0.5;%ap=-20*log10(1-dp)
as=80;%as=-20*log10(ds)
dp=1-10^(-ap/20);
ds=10^(-as/20);
[N,W,bta,filtype] = kaiserord( [300 450 550 650 ], [1 0 1], [dp ds dp], samp );
w = window(@kaiser,N+1,bta);
figure
subplot 121, plot(1:N+1,w);
b = fir1(N, W, filtype, kaiser(N+1,bta), 'noscale');
[h,o]=freqz(b,1,256);
subplot 122, plot(o/pi, 20*log10(abs(h)));
y=filter(b,1,x);
figure
subplot 211, plot(abs(fft(x)));
subplot 212, plot(abs(fft(y)));

No comments: