clear;close all
[z1,fs,bits]=wavread('F:\\wqk.wav') y1=z1(1:8192); Y1=fft(y1);
fs=8000;f=[2800,3000]; m=[0,1]; rp=1;rs=100;
dat1=(10^(rp/20)-1)/(10^(rp/20)+1);dat2=10^(-rs/20); rip=[dat2,dat1];
[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); 图形:
(3)带通滤波器 程序:
clear;close all
[z1,fs,bits]=wavread('F:\\wqk.wav')
y1=z1(1:8192);
Y1=fft(y1);
fs=8000;f=[1000,1200,3000,3200]; m=[0,1,0]; rp=1;rs=100;
dat1=(10^(rp/20)-1)/(10^(rp/20)+1);dat2=10^(-rs/20); rip=[dat2,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); 图形:
(4)双线性变换法设计低通滤波器 选用butter 程序设计如下: clear;close all
[z1,fs,bits]=wavread('F:\\wqk.wav') y1=z1(1:8192); Y1=fft(y1);
fp=1000;fc=1200;As=100;Ap=1;Fs=8000; wc=2*fc/Fs; wp=2*fp/Fs; [N,ws]=buttord(wc,wp,Ap,As); [b,a]=butter(N,ws); figure(1);
freqz(b,a,512,Fs); x=filter(b,a,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); 图如下: