用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通高通_第1頁
用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通高通_第2頁
用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通高通_第3頁
用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通高通_第4頁
用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通高通_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、用matlab設(shè)計(jì)的IIR濾波器源程序-IIR一階低通/高通用matlab設(shè)計(jì)的IIR濾波器源程序(1)IIR一階低通濾波器P576clear;fi=1;fs=10;Gc2=0.9;wc=2*pi*fi/fs;omegac=tan(wc/2);alpha=(sqrt(Gc2)/sqrt(1-Gc2)*omegac;a=(1-alpha)/(1+alpha);b=(1-a)/2;w=0:pi/300:pi;Hw2=alpha2./(alpha2+(tan(w/2).2);plot(w/pi,Hw2);grid;holdon;(2)一階高通濾波器P581clear;fi=1;fs=10;Gc2=0

2、.5;wc=2*pi*fi/fs;omegac=tan(wc/2);alpha=(sqrt(1-Gc2)/(sqrt(Gc2)*omegac;a=(1-alpha)/(1+alpha);b=用matlab設(shè)計(jì)的IIR濾波器源程序(1)IIR一階低通濾波器 P576clear;fi=1;fs=10;Gc2=0.9;wc=2*pi*fi/fs;omegac=tan(wc/2);alpha=(sqrt(Gc2)/sqrt(1-Gc2)*omegac;a=(1-alpha)/(1+alpha);b=(1-a)/2;w=0:pi/300:pi;Hw2=alpha2./(alpha2+(tan(w/2).

3、2);plot(w/pi,Hw2);grid;holdon;(2)一階高通濾波器 P581clear;fi=1;fs=10;Gc2=0.5;wc=2*pi*fi/fs;omegac=tan(wc/2);alpha=(sqrt(1-Gc2)/(sqrt(Gc2)*omegac;a=(1-alpha)/(1+alpha);b=(1+a)/2;w=0:pi/300:pi;Hw2=(tan(w/2).2)./(alpha2+(tan(w/2).2);plot(w/pi,Hw2);grid;hold on;(3)Notch 嵌波濾波器clear;Gb2=0.5;w0=0.35*pi;deltaw=0.1

4、*pi;b=1/(1+tan(deltaw/2)*(sqrt(1-Gb2)/sqrt(Gb2);B=1 -2*cos(w0) 1.*b;A=1 -2*b*cos(w0) (2*b-1);w=0:pi/500:pi;H=freqz(B,A,w);plot(w/pi,abs(H);grid;(4)Peak 濾波器clear;Ac=3;Gb2=10(-Ac/10);w0=0.35*pi;deltaw=0.1*pi;b=1/(1+tan(deltaw/2)*(sqrt(Gb2)/sqrt(1-Gb2);B=1 0 -1.*(1-b);A=1 -2*b*cos(w0) (2*b-1);w=0:pi/50

5、0:pi;H=freqz(B,A,w);plot(w/pi,abs(H);grid;(5)IIR低通濾波(Butterworth)% IIR Lowpass Use Butterworth% copyright by Etualclear;fs=20;fpass=4;fstop=5;Ap=0.5;As=10;wp=2*pi*fpass/fs;ws=2*pi*fstop/fs;omegap=tan(wp/2);omegas=tan(ws/2);ep=sqrt(10(Ap/10)-1);es=sqrt(10(As/10)-1);N=ceil(log(es/ep)/log(omegas/omegap

6、);omega0=omegap/ep(1/N);K=floor(N/2);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endfor i=1:K G(i)=omega02/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:Ka1(i)=2*(omega02-1)/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a2(i)=(1+2*omega0*cos(theta(i)+omega02)/(1-2*omega0*cos(theta(i)+omega02);endif K(N/2)

7、 G0=omega0/(omega0+1);a0=(omega0-1)/(omega0+1);endw=0:pi/300:pi;Hw2=1./(1+(tan(w/2)/omega0).(2*N);plot(w/pi,Hw2);grid;(6)IIR高通濾波(Butterworth)% IIR Hightpass Use Butterworth% copyright by Etualclear;fs=20;fpass=5;fstop=4;Ap=0.5;As=10;wp=2*pi*fpass/fs;ws=2*pi*fstop/fs;omegap=cot(wp/2);omegas=cot(ws/2)

8、;ep=sqrt(10(Ap/10)-1);es=sqrt(10(As/10)-1);N=ceil(log(es/ep)/log(omegas/omegap);omega0=omegap/ep(1/N);K=floor(N/2);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endfor i=1:K G(i)=omega02/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a1(i)=-2*(omega02-1)/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a2(i)=

9、(1+2*omega0*cos(theta(i)+omega02)/(1-2*omega0*cos(theta(i)+omega02);endif K(N/2) G0=omega0/(omega0+1);a0=-(omega0-1)/(omega0+1);endw=(0+eps):pi/300:pi;Hw2=1./(1+(cot(w/2)/omega0).(2*N);plot(w/pi,Hw2);grid;(7)IIR帶通濾波(Butterworth)% IIR Bandpass Use Butterworth% copyright by Etualclear;fs=20;fpa=2;fpb=

10、4;fsa=1.5;fsb=4.5;Ap=0.0877;As=16.9897;wpa=2*pi*fpa/fs;wpb=2*pi*fpb/fs;wsa=2*pi*fsa/fs;wsb=2*pi*fsb/fs;c=sin(wpa+wpb)/(sin(wpa)+sin(wpb);omegap=abs(c-cos(wpb)/sin(wpb);omegasa=(c-cos(wsa)/sin(wsa);omegasb=(c-cos(wsb)/sin(wsb);omegas=min(abs(omegasa),abs(omegasb);ep=sqrt(10(Ap/10)-1);es=sqrt(10(As/10

11、)-1);N=ceil(log(es/ep)/log(omegas/omegap);omega0=omegap/ep(1/N);K=floor(N/2);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endfor i=1:K G(i)=omega02/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a1(i)=4*c*(omega0*cos(theta(i)-1)/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a2(i)=2*(2*c2+1-omega02)/(1-2*o

12、mega0*cos(theta(i)+omega02);endfor i=1:K a3(i)=-(4*c*(omega0*cos(theta(i)+1)/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a4(i)=(1+2*omega0*cos(theta(i)+omega02)/(1-2*omega0*cos(theta(i)+omega02);endif K(N/2) G0=omega0/(1+omega0);a0(1)=-2*c/(1+omega0);a0(2)=(1-omega0)/(1+omega0);endw=(0+eps):pi/30

13、0:pi;Hw2=1./(1+(c-cos(w)./(omega0*sin(w).(2*N);plot(w/pi,Hw2);grid;(8)IIR帶阻濾波(Butterworth)% IIR Bandstop Use Butterworth% copyright by Etualclear;fs=20;fpa=1.5;fpb=4.5;fsa=2;fsb=4;Ap=0.5;As=10;wpa=2*pi*fpa/fs;wpb=2*pi*fpb/fs;wsa=2*pi*fsa/fs;wsb=2*pi*fsb/fs;c=sin(wpa+wpb)/(sin(wpa)+sin(wpb);omegap=ab

14、s(sin(wpb)/(c-cos(wpb);omegasa=sin(wsa)/(cos(wsa)-c);omegasb=sin(wsb)/(cos(wsb)-c);omegas=min(abs(omegasa),abs(omegasb);ep=sqrt(10(Ap/10)-1);es=sqrt(10(As/10)-1);N=ceil(log(es/ep)/log(omegas/omegap);omega0=omegap/ep(1/N);K=floor(N/2);theta=zeros(1,K);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endG=zeros(

15、1,K);a1=zeros(1,K);a2=zeros(1,K);for i=1:K G(i)=omega02/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a1(i)=2*(omega02-1)/(1-2*omega0*cos(theta(i)+omega02);endfor i=1:K a2(i)=(1+2*omega0*cos(theta(i)+omega02)/(1-2*omega0*cos(theta(i)+omega02);endif K(N/2) G0=omega0/(omega0+1);a0=(omega0-1)/(omega0+

16、1);endw=(0+eps):pi/300:pi;Hw2=1./(1+(sin(w)./(omega0*(c-cos(w).(2*N);plot(w/pi,Hw2);grid;(9)IIR低通濾波(chebyshev 1)% IIR Lowpass Use Chebyshev Type 1% copyright by Etualclear;fs=20;fpass=4;fstop=5;Ap=0.5;As=10;wp=2*pi*fpass/fs;ws=2*pi*fstop/fs;omegap=tan(wp/2);omegas=tan(ws/2);ep=sqrt(10(Ap/10)-1);es=s

17、qrt(10(As/10)-1);e=es/ep;w=omegas/omegap;N=ceil(log(e+sqrt(e2-1)/log(w+sqrt(w2-1);a=log(1/ep+sqrt(1/ep2+1)/N;omega0=omegap*sinh(a);K=floor(N/2);theta=zeros(1,K);omega=zeros(1,K);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endfor i=1:K omega(i)=omegap*sin(theta(i);endG=zeros(1,K);a1=zeros(1,K);a2=zeros(1,K

18、);for i=1:K G(i)=(omega02+omega(i)2)/(1-2*omega0*cos(theta(i)+omega02+omega(i)2);endfor i=1:K a1(i)=2*(omega02+omega(i)2-1)/(1-2*omega0*cos(theta(i)+omega02+omega(i)2);endfor i=1:K a2(i)=(1+2*omega0*cos(theta(i)+omega02+omega(i)2)/(1-2*omega0*cos(theta(i)+omega02+omega(i)2);endif K(N/2) G0=omega0/(o

19、mega0+1);a0=(omega0-1)/(omega0+1);else H0=sqrt(1/(1+ep2);endf=0:1/300:10;Hf2=1./(1+ep2*(cheby(N,tan(pi*f/fs)/omegap).2);plot(f,abs(Hf2);grid;(9)IIR低通濾波(chebyshev 1)% IIR Lowpass Use Chebyshev Type 2% copyright by Etualclear;fs=20;fpass=4;fstop=5;Ap=0.5;As=10;wp=2*pi*fpass/fs;ws=2*pi*fstop/fs;omegap=tan(wp/2);omegas=tan(ws/2);ep=sqrt(10(Ap/10)-1);es=sqrt(10(As/10)-1);e=es/ep;w=omegas/omegap;N=ceil(log(e+sqrt(e2-1)/log(w+sqrt(w2-1);a=log(es+sqrt(es2+1)/N;omega0=omegas/sinh(a);K=floor(N/2);for i=1:K theta(i)=pi*(N-1+2*i)/(2*N);endfor i=1:K omega(i)=omegas/sin(theta(i);endfor i=1:K G(i)=(1+om

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論