您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > IIR数字滤波器设计及软件实现程序代码matlab
实验四:IIR数字滤波器设计及软件实现1、原信号函数(1)原信号程序functionst=mgstN=800;Fs=10000;T=1/Fs;Tp=N*T;t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;fc1=Fs/10;fm1=fc1/10;fc2=Fs/20;fm2=fc2/10;fc3=Fs/40;fm3=fc3/10;xt1=cos(2*pi*fm1*t).*cos(2*pi*fc1*t);xt2=cos(2*pi*fm2*t).*cos(2*pi*fc2*t);xt3=cos(2*pi*fm3*t).*cos(2*pi*fc3*t);st=xt1+xt2+xt3;fxt=fft(st,N);subplot(4,1,1);plot(t,st);grid;xlabel('t/s');ylabel('s(t)');axis([0,Tp/8,min(st),max(st)]);title('(a)s(t)µÄÐÎ');subplot(4,1,2);stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b)y(t)µÄƵÆ×')axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('·ù¶È')(2)输出波形2、高通滤波器(1)程序设计%高通滤波器设计fp=800;fs=700;Fs=10000;wp=2*fp/Fs;ws=2*fs/Fs;rp=1;rs=40;N=800;st=mgst;T=1/Fs;Tp=N*T;t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;[N1,wpo]=ellipord(wp,ws,rp,rs);[B,A]=ellip(N1,rp,rs,wpo,'high');y=filter(B,A,st);fyt=fft(y,N);figure(2);subplot(2,1,1),plot(t,y),grid,xlabel('t/y'),ylabel('y(t)'),axis([0,Tp/8,min(y),max(y)]),title('(a)y(t)µÄ²¨ÐÎ')subplot(2,1,2);stem(f,abs(fyt)/max(abs(fyt)),'.');grid;title('(b)y(t)µÄƵÆ×')axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('·ù¶È')(2)输出波形3、带通滤波器(1)设计程序%带通滤波器fpl=400;fpu=600;fsl=350;fsu=650;Fs=10000;wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];rp=1;rs=40;N=800;st=mgst;T=1/Fs;Tp=N*T;t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;[N1,wpo]=ellipord(wp,ws,rp,rs);[B,A]=ellip(N1,rp,rs,wpo);fyt=fft(y,N);figure(2);subplot(2,1,1),plot(t,y),grid,xlabel('t/y'),ylabel('y(t)'),axis([0,Tp/8,min(y),max(y)]),title('(a)y(t)µÄ²¨ÐÎ')subplot(2,1,2);y=filter(B,A,st);stem(f,abs(fyt)/max(abs(fyt)),'.');grid;title('(b)y(t)µÄƵÆ×')axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('·ù¶È')(2)输出波形4、低通滤波器设计(1)设计程序%低通滤波器fp=350;fs=400;Fs=10000;wp=2*fp/Fs;ws=2*fs/Fs;rp=1;rs=40;N=800;st=mgst;T=1/Fs;Tp=N*T;t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;[N1,wpo]=ellipord(wp,ws,rp,rs);[B,A]=ellip(N1,rp,rs,wpo);y=filter(B,A,st);fyt=fft(y,N);figure(2);subplot(2,1,1),plot(t,y),grid,xlabel('t/y'),ylabel('y(t)'),axis([0,Tp/8,min(y),max(y)]),title('(a)y(t)µÄ²¨ÐÎ')subplot(2,1,2);stem(f,abs(fyt)/max(abs(fyt)),'.');grid;title('(b)y(t)µÄƵÆ×')axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('·ù¶È')(2)输出波形5、带阻滤波器(1)程序如下%´ø×èÂ˲¨Æ÷Éè¼Æfpl=350;fpu=700;fsl=400;fsu=600;Fs=10000;wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];rp=1;rs=40;N=800;st=mgst;T=1/Fs;Tp=N*T;t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;[N1,wpo]=ellipord(wp,ws,rp,rs);[B,A]=ellip(N1,rp,rs,wpo,'stop');y=filter(B,A,st);fyt=fft(y,N);figure(2);subplot(2,1,1),plot(t,y),grid,xlabel('t/y'),ylabel('y(t)'),axis([0,Tp/8,min(y),max(y)]),title('(a)y(t)µÄ²¨ÐÎ')subplot(2,1,2);stem(f,abs(fyt)/max(abs(fyt)),'.');grid;title('(b)y(t)µÄƵÆ×')axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('·ù¶È')(2)输出波形
本文标题:IIR数字滤波器设计及软件实现程序代码matlab
链接地址:https://www.777doc.com/doc-4395539 .html