www.pudn.com > MATLAB.rar > exa070902_fir2.m


>---------------------------------------------------------------------------
> exa070902_fir2.m, for example 7.9.2 and to test fir2,
>---------------------------------------------------------------------------
clear all;

f=[0 0.19 0.2 0.3 0.31 0.59 0.6 0.8 0.81 1];
> 给定频率轴分点;
m=[0 0 1 1 0 0 1 1 0 0];
> 给定在这些频率分点上理想的幅频响应
N1=30;
N2=90;
> 取两种不同的滤波器长度;
b1=fir2(N1,f,m);
b2=fir2(N2,f,m);
> 得到两个滤波器;

subplot(311);
stem(b1,'.');grid;
subplot(312);
stem(b2,'.');grid;

M=128;
[h1,w]=freqz(b1,1,M,1);
[h2,w]=freqz(b2,1,M,1);
subplot(313);
plot(w,abs(h1),'b-',w,abs(h2),'g-');grid;