1.确定参数:
Wp 通带截止频率
Ws 阻带截止频率
As 衰减dB
Rp 纹波dB
2.根据参数确定理想 频率响应 (M (Wp + Ws )/2 )
3.选窗
过滤带宽
阻带衰减
4.得出最终响应
时域相乘 频域卷积
5.观察各项参数是否达标(采用归一化后的数据)
衰减
幅频特性
相频
群延时 ??
···
Ps:观察频率响应的函数
这里a = 1 因为FIR可由差分方程描述
故分母为1
代码:
wp =0.2*pi;
ws = 0.3*pi;
tr_width = ws -wp;
M = ceil(6.6*pi/tr_width)+1;
n = [0:1:M-1];
wc = ((ws + wp)/2) %ideal LPF cutoff frequency
hd = ideal_lp(wc,M);
w_ham = (hamming(M))\';
h = hd .* w_ham;
[db,mag,pha,grd,w] = freqz_m(h,[1]);
delta_w = 2*pi/1000;
Rp = -(min(db(1:1:wp/delta_w+1)));
As = -round(max(db(ws/delta_w+1:1:501)));
%plot
subplot(2,2,1);
stem(n,hd);
title(\'Ideal Impulse Response\');
axis([0 M-1 -0.1 0.3]);
xlabel(\'n\');
ylabel(\'hd(n)\');
subplot(2,2,2);
stem(n,w_ham);
title(\' Hamming Window\');
axis([0 M-1 0 1.1]);
xlabel(\'n\');
ylabel(\'w(n)\');
subplot(2,2,3);
stem(n,h);
title(\'Actual Impluse Response\');
axis([0 M-1 -0.1 0.3]);
xlabel(\'n\');
ylabel(\'h(n)\');
subplot(2,2,4);
plot(w/pi,db);
title(\'Magnitude Response in dB\');grid
axis([0 1 -100 10]);
xlabel(\'frequency in pi units\');
ylabel(\'Decibels\');
带通:
wp1 =0.35*pi;
ws1 = 0.2*pi;
wp2 =0.65*pi;
ws2 = 0.8*pi;
tr_width = min((wp1 -ws1),(ws2 - wp2));
M = ceil(11*pi/tr_width)+1;
M
n = [0:1:M-1];
wc1 = ((ws1 + wp1)/2);
wc2 = ((ws2 + wp2)/2);
hd = ideal_lp(wc2,M)-ideal_lp(wc1,M);
w_ham = (blackman(M))\';
h = hd .* w_ham;
[db,mag,pha,grd,w] = freqz_m(h,[1]);
delta_w = 2*pi/1000;
Rp = -(min(db(wp1/delta_w+1:1:wp2/delta_w+1)));
Rp
As = -round(max(db(ws2/delta_w+1:1:501)));
As
%plot
subplot(2,2,1);
stem(n,hd);
title(\'Ideal Impulse Response\');
axis([0 M-1 -0.5 0.5]);
xlabel(\'n\');
ylabel(\'hd(n)\');
subplot(2,2,2);
stem(n,w_ham);
title(\' blackman Window\');
axis([0 M-1 0 1.1]);
xlabel(\'n\');
ylabel(\'w(n)\');
subplot(2,2,3);
stem(n,h);
title(\'Actual Impluse Response\');
axis([0 M-1 -0.5 0.5]);
xlabel(\'n\');
ylabel(\'h(n)\');
subplot(2,2,4);
plot(w/pi,db);
title(\'Magnitude Response in dB\');grid
axis([0 1 -150 10]);
xlabel(\'frequency in pi units\');
ylabel(\'Decibels\');