用Kaiser窗函数法设计FIR数字带通滤波器,设计指标为:wp1=0.35pi,wp2=0.65pi,ws1=0.2pi,ws2=0.8pi,Rp=1db,Rs=60db,matlab代码中文
时间: 2023-07-14 14:12:17 浏览: 220
以下是使用Kaiser窗函数法设计FIR数字带通滤波器的MATLAB代码:
```matlab
% 设计指标
wp1 = 0.35*pi; % 通带边界频率1
wp2 = 0.65*pi; % 通带边界频率2
ws1 = 0.2*pi; % 阻带边界频率1
ws2 = 0.8*pi; % 阻带边界频率2
Rp = 1; % 通带最大衰减
Rs = 60; % 阻带最小衰减
% 计算通带和阻带宽度
Wp = wp2 - wp1;
Ws = ws2 - ws1;
% 计算过渡带宽度
if Ws > Wp
A = -20*log10(sqrt(1/Rs - 1));
delta = sqrt(1/Rp - 1)/sqrt(1/Rs - 1);
N = ceil((A - 8)/(2.285*Ws/Wp));
else
delta = sqrt(1/Rp - 1);
A = -20*log10(delta);
N = ceil((A - 8)/(4.57*Ws/Wp));
end
% 计算Kaiser窗函数参数
beta = 0.1102*(A - 8.7);
if A <= 21
beta = 0;
end
% 计算Kaiser窗函数长度和系数
n = 0:N;
wc1 = (wp1+ws1)/2;
wc2 = (wp2+ws2)/2;
h = (sin(wc2*(n-N/2))-sin(wc1*(n-N/2)))./(pi*(n-N/2));
w = kaiser(N+1,beta)';
h = h.*w;
% 绘制滤波器幅频响应
[H,f] = freqz(h,1,1024,2*pi);
plot(f/(2*pi),20*log10(abs(H)));
xlabel('频率/Hz');
ylabel('幅值/dB');
title('FIR数字带通滤波器');
```
其中,输出的为滤波器的幅频响应图像。
阅读全文