freqz(b,1); x=fftfilt(b,z1); X=fft(x,8192); figure(2);
subplot(2,2,1);plot(abs(Y1));axis([0,4000,0,1.0]); title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));axis([0,4000,0,1.0]); title('滤波后信号频谱'); subplot(2,2,3);plot(z1); title('滤波前信号波形'); subplot(2,2,4);plot(x); title('滤波后信号波形'); sound(x,fs,bits); 图如下:
(3)窗函数设计带通滤波器 程序设计如下: clear;close all
[z1,fs,bits]=wavread('F:\\wqk.wav') y1=z1(1:8192); Y1=fft(y1);
fp1=1200 ;fp2=3000 ;fc1=1000 ;fc2=3200 ;As=100 ;Ap=1 ;Fs=8000 ; wp1=2*pi*fp1/Fs; wc1=2*pi*fc1/Fs; wp2=2*pi*fp2/Fs; wc2=2*pi*fc2/Fs; wdel=wp1-wc1; beta=0.112*(As-8.7); N=ceil((As-8)/2.285/wdel);
ws =[(wp1+wc1)/2/pi,(wp2+wc2)/2/pi]; wn= kaiser(N+1,beta); b=fir1(N,ws,wn); figure(1); freqz(b,1)
x=fftfilt(b,z1); X=fft(x,8192); figure(2);
subplot(2,2,1);plot(abs(Y1));axis([0,4000,0,1.0]); title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));axis([0,4000,0,1.0]); title('滤波后信号频谱') subplot(2,2,3);plot(z1); title('滤波前信号波形'); subplot(2,2,4);plot(x); title('滤波后信号波形'); sound(x,fs,bits); 图如下:
4、等波纹逼近法 (1)低通滤波器 clear;close all
[z1,fs,bits]=wavread('F:\\wqk.wav') y1=z1(1:8192); Y1=fft(y1);
fs=8000;f=[1000,1200];
m=[1,0]; rp=1;rs=100;
dat1=(10^(rp/20)-1)/(10^(rp/20)+1);dat2=10^(-rs/20); rip=[dat1,dat2];
[M,fo,mo,w]=remezord(f,m,rip,fs); hn=remez(M,fo,mo,w); figure(1); freqz(hn);
x=filter(hn,1,y1); X=fft(x,8192); figure(2);
subplot(2,2,1);plot(abs(Y1));axis([0,4000,0,1.0]); title('滤波前信号频谱');
subplot(2,2,2);plot(abs(X));axis([0,4000,0,0.03]); title('滤波后信号频谱'); subplot(2,2,3);plot(z1);
title('滤波前信号波形'); subplot(2,2,4);plot(x); title('滤波后信号波形'); sound(x,fs,bits);: 图如下:
(2)高通滤波器 程序: