2-1用窗函数法设计一个线性相位FIR低通滤波器,并满足性能指标:通带边界频率
Wp=0.5*pi,阻带边界频率Ws=0.66*pi,阻带衰减不小于40dB,通带波纹不大于3dB。选择汉宁窗。
代码:
wp =0.5*pi;
ws=0.66*pi;
wdelta =ws-wp;
N= ceil(8*pi/wdelta)
if rem(N,2)==0
N=N+1;
end
Nw =N;
wc =(wp+ws)/2;
n =0: N-1;
alpha =(N-1)/2;
m =n-alpha+0.00001;
hd =sin(wc*m)./(pi*m);
win =(hanning(Nw))';
h=hd.*win;
b=h;
freqz(b,1,512)
运行结果:
图5线性相位低通滤波器幅频-相频特性
2-4用海明窗设计一个FIR滤波器,其中Wp=0.2*pi,Ws=0.3*pi,通带衰减不大于0.25dB,阻带衰减不小于50dB。
代码:
wp=0.2*pi;
ws=0.3*pi;
tr_width=ws-wp;
M=ceil(6.6*pi/tr_width)+1;
n=[0: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:1:501))) %Min stopband attenuation
%Plots
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 Impulse Response')
axis([0 M-1 -0.1 0.3]);
xlabel('n');ylabel('h(n)');
%%%%%%
运行结果:
图6低通FIR滤波器
第一程序可运行,第二程序还差三句,我有6个,要全的话,给分吧