凯瑟窗函数法设计FIR数字带通滤波器,设计指标为:wp1=0.35pi,wp2=0.65pi,ws1=0.2pi,ws2=0.8pi,Rp=1db,Rs=60db,matlab代码中文
时间: 2023-07-14 15:12:05 浏览: 158
以下是使用凯瑟窗函数法设计FIR数字带通滤波器的MATLAB代码:
```matlab
% 设计指标
wp1 = 0.35*pi;
wp2 = 0.65*pi;
ws1 = 0.2*pi;
ws2 = 0.8*pi;
Rp = 1;
Rs = 60;
% 计算参数
delta_p = (10^(Rp/20)-1)/(10^(Rp/20)+1);
delta_s = 10^(-Rs/20);
A = -20*log10(min(delta_p,delta_s));
N = ceil((A-8)/(4.57*(wp2-wp1)/(2*pi)));
beta = 0.1102*(A-8.7);
% 计算凯瑟窗函数
n = 0:N-1;
wnd = kaiser(N,beta);
% 计算理想频率响应
wc1 = (wp1+ws1)/2;
wc2 = (wp2+ws2)/2;
hd = (sin(wc2*(n-N/2))-sin(wc1*(n-N/2)))./(pi*(n-N/2));
hd(N/2+1) = (wc2-wc1)/pi;
% 计算实际频率响应
h = hd.*wnd';
% 绘制幅频响应曲线
[H,w] = freqz(h,1,1024);
magH = 20*log10(abs(H));
plot(w/pi,magH);
xlabel('归一化频率');
ylabel('幅度(dB)');
title('FIR数字带通滤波器幅频响应');
grid on;
```
其中,kaiser函数用于计算凯瑟窗函数,freqz函数用于计算幅频响应。运行以上代码,即可得到数字带通滤波器的幅频响应曲线。
阅读全文