实验四:IIR数字滤波器设计及软件实现
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验四: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)'),
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)'),
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;