matlab 自编的窗函数设计FIR滤波器程序出问题了 急!!!

发布时间:2024-05-10 12:21 发布:上海旅游网

问题描述:

function [N,wn]=kaiser(fp,fs,as,FS)%kaiser 窗函数
B=2*pi*(fs-fp)/FS %滤波器的过渡带宽
As=-20*log10(as)
if As<=21
bata=0;
elseif (As>21&As<50)
bata=0.5842*(As-21)^0.4+0.07886*(As-21);
else
bata=0.1102*(As-8.7);
end
bata
N=((As-7.95)/2.286*B)+1;
N=round(N)%取最接近N的整数
n=0:N-1;
wn=bessel(0,bata*(1-(1-2*n/(N-1)).^2).^0.5)/bessel(0,bata)%用公式计算凯撒窗
function wn=hanning(N)
n=0:N-1;
wn=0.5-0.5*cos(2*pi*n/(N-1));
使用test函数测试
fp=2000;fs=2500;as=0.005;FS=10000;
wc=pi*(fs+fp)/FS %数字滤波器的截止频率
[N,wn0]=kaiser(fp,fs,as,FS);
n=0:N-1;
hdn0=myhd(N,wc);
for i=1:N
hn0(i)=hdn0(i).*wn0(i)
end
M=N;
hdn1=myhd(M,wc);
wn1=hanning(M);
wn2=bulaikeman(M);
for i=1:M
hn1(i)=hdn1(i).*wn1(i)
end
a0=[1]%H0(Z)的分母系数
b0=hn0./sum(hn0)%H0(Z)的分子系数
a1=[1]%H1(Z)的分母系数
b1=hn1./sum(hn1)%H1(Z)的分子系数
[ h0,w]=freqz(b0,a0);%求凯泽窗设计的滤波器的频率响应
[ h1,w]=freqz(b1,a1);%求汉宁窗设计的滤波器的频率响应
w0=w/(2*pi);
subplot(3,2,1);
plot(n,hn0)
grid on;
xlabel('n');
ylabel('kaiser-h0(n)');
m=0:M-1
subplot(3,2,3);
plot(m,hn1)
xlabel('n');
ylabel('hanning-h1(n)');
grid on;

问题解答:

matlab 自编的窗函数设计FIR滤波器程序出问题了 急!!!这个旅游问答期待您的解答,请登录账号或关注微信公众号回答这个问题。

热点新闻