www.pudn.com > fftfiltler.rar > exa070903_remez_2.m, change:2006-06-09,size:1158b


%-------------------------------------------------------------------------- 
% exa070903_remez_2.m,   for example 7.9.3 and 7.4.2; 
% to test remez.m and to design multi-band FIR filter; 
%------------------------------------------------------------------------- 
clear all; 
clf;             %清屏 
clear;           %清变量 
w(1)=0.95;%0.95; 
r(1)=0.80; 
N=1024*2;          %设置采样数据的个数 
for t=1:N        %计算产生系数w(t)和r(t) 
    w(t+1)=0.99*w(t)+0.01; 
    r(t+1)=0.99*r(t)+0.00995; 
end 
 
dt=1/8000;        %设置采样频率 
tt=0:dt:dt*N;   %采样时间 
%dis=2*(rand(size(tt)));          %产生随机噪声数据 
%y=1000*sin(2*pi*1000*tt)+8*dis;   %产生加有噪声的正弦信号 
y=wavread('single440Hz100db.wav'); 
y=y(:,1); 
p0=10000/mean(y'*y);         %计算信号的均值 
%p0=1000/mean(y); 
 
 
% 用切比雪夫最佳一致逼近设计线性相位多带FIR滤波器; 
f=[0 .14 .18 .22 .26 .34 .38 .42 .46 .54 .58 .62 .66 1]; 
A=[1 1  0 0 1 1 0 0 1 1 0 0 1 1]; 
weigh=[8 1 8 1 8 1 8];	 
b=remez(128,f,A,weigh); 
% 
[h,w]=freqz(b,1,256,1); 
hr=abs(h); 
h=abs(h); 
h=20*log10(h); 
figure(1) 
stem(b,'.');grid; 
figure(2) 
plot(w,h);grid; 
qq=filter(w,h,y); 
wvtool(y); 
wvtool(qq);