资源描述:
《matlab滤波器代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数字信号处理:已知通带截止频率fp=5kHz,通带最大衰减ap=2dB,阻带截止频率fs=2kHz,阻带最小衰减as=30dB,按照以上技术指标设计巴特沃斯低通滤波器:wp=2*pi*5000;ws=2*pi*12000;Rp=2;As=30;[N,wc]=buttord(wp,ws,Rp,As,'s');[B,A]=butter(N,wc,'s');k=0:511;fk=0:14000/512:14000;wk=2*pi*fk;Hk=freqs(B,A,wk);subplot(2,2,1);plot(fk/1000,20*log10(abs(Hk)));gridonxlabel('频
2、率(kHz)');ylabel('幅度(dB)')axis([0,14,-40,5])切比雪夫1型低通滤波器:wp=2*pi*3000;ws=2*pi*12000;Rp=0.1;As=60;[N1,wpl]=cheb1ord(wp,ws,Rp,As,'s');%cheb1ord,里面的是1,不是L[B1,A1]=cheby1(N1,Rp,wpl,'s');subplot(2,2,1);fk=0:12000/512:12000;wk=2*pi*fk;Hk=freqs(B1,A1,wk);plot(fk/1000,20*log10(abs(Hk)));gridonxlabel('频率(kH
3、z)');ylabel('幅度(dB)')axis([0,12,-70,5])椭圆模拟低通滤波器:wp=2*pi*3000;ws=2*pi*12000;Rp=0.1;As=60;[N,wpo]=ellipord(wp,ws,Rp,As,'s');[B,A]=ellip(N,Rp,As,wpo,'s');subplot(2,2,1);fk=0:12000/512:12000;wk=2*pi*fk;Hk=freqs(B1,A1,wk);plot(fk/1000,20*log10(abs(Hk)));gridonxlabel('频率(kHz)');ylabel('幅度(dB)')axis([
4、0,12,-70,5])p195-14wp=2*4/80;ws=2*20/80;rp=0.5;rs=45;[N,wc]=buttord(wp,ws,rp,rs);[B,A]=butter(N,wc);[hk,wk]=freqz(B,A);fk=wk/pi*40;plot(fk,20*log10(abs(hk)));axis([0,30,-100,0])xlabel('频率(kHZ)');ylabel('幅度(db)');gridonP195-16wp=2*325/2500;ws=2*225/2500;rp=1;rs=40;[N,wc]=ellipord(wp,ws,rp,rs);[B,
5、A]=ellip(N,rp,rs,wc);[hk,wk]=freqz(B,A);fk=wk/pi*40;plot(fk,20*log10(abs(hk)));axis([0,30,-100,0])xlabel('频率(kHZ)');ylabel('幅度(db)');gridonP195-15wp=2*4/80;ws=2*20/80;rp=0.5;rs=45;[N,wc]=cheb1ord(wp,ws,rp,rs);[B,A]=cheby1(N,rp,wc);[hk,wk]=freqz(B,A);fk=wk/pi*40;plot(fk,20*log10(abs(hk)));axis([0
6、,30,-100,0])xlabel('频率(kHZ)');ylabel('幅度(db)');gridon切比雪夫低通滤波器wp=2*pi*3000;ws=2*pi*12000;rp=0.1;as=60;[N1,wp1]=cheb1ord(wp,ws,rp,as,'s');[B1,A1]=cheby1(N1,rp,wp1,'s');subplot(2,2,1);fk=0:12000/512:12000;wk=2*pi*fk;hk=freqs(B1,A1,wk);plot(fk/1000,20*log10(abs(hk)));gridonxlabel('频率(kHZ)');ylabel(
7、'幅度(db)');axis([0,12,-70,5])双音频检测audiofile='test.wav'[in_audio,fs,bits]=wavread(audiofile);[b,a]=cheby1(5,0.1,0.3);out_audio=filter(b,a,in_audio);sound(out_audio,fs,bits);wavwrite(out_audio,fs,bits,'test_out');xk1=fft(in_aud