IIR滤波器matlab源程序

上传人:m**** 文档编号:485489366 上传时间:2023-10-02 格式:DOC 页数:14 大小:59.50KB
返回 下载 相关 举报
IIR滤波器matlab源程序_第1页
第1页 / 共14页
IIR滤波器matlab源程序_第2页
第2页 / 共14页
IIR滤波器matlab源程序_第3页
第3页 / 共14页
IIR滤波器matlab源程序_第4页
第4页 / 共14页
IIR滤波器matlab源程序_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《IIR滤波器matlab源程序》由会员分享,可在线阅读,更多相关《IIR滤波器matlab源程序(14页珍藏版)》请在金锄头文库上搜索。

1、IIR滤波器matlab源程序(1)IIR一阶低通滤波器 clear;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;hold on;(2)一阶高通滤波器 clear;fi=1;fs=10;Gc2=0.5;wc=2*pi*fi/fs;omegac=tan(wc/2);alp

2、ha=(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*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:

3、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/500:pi;H=freqz(B,A,w);plot(w/pi,abs(H);grid;(5)IIR低通滤波(Butterworth)% IIR Lowpass Use Butterworthclear;fs=2

4、0;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);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

5、)+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+1);endw=0:pi/300:pi;Hw2=1./(1+(tan(w/2)/omega0).(2*N);plot(w/pi,Hw2);grid;(6)II

6、R高通滤波(Butterworth)% IIR Hightpass Use Butterworthclear;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);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

7、*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)=(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

8、/300:pi;Hw2=1./(1+(cot(w/2)/omega0).(2*N);plot(w/pi,Hw2);grid;(7)IIR带通滤波(Butterworth)% IIR Bandpass Use Butterworthclear;fs=20;fpa=2;fpb=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(

9、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)-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(

10、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*omega0*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)

11、/(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/300:pi;Hw2=1./(1+(c-cos(w)./(omega0*sin(w).(2*N);plot(w/pi,Hw2);grid;(8)IIR带阻滤波(Butterworth)% IIR Bandstop Use Butterworthclear;fs=20;fpa=1.5;fpb=4.5;fsa=2;fsb=4;Ap=

12、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=abs(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

13、(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(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*om

14、ega0*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+(sin(w)./(omega0*(c-cos(w).(2*N);plot(w/pi,Hw2);grid;(9)IIR低通滤波(chebyshev 1)% IIR Lowpass Use Chebyshev Type 1clear;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);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号