实验四:IIR数字滤波器设计及软件实现
1、 原信号函数
(1)原信号程序
function st=mgst
N=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)输出波形
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- howto234.com 版权所有 湘ICP备2022005869号-3
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务