IIR数字滤波器设计及软件实现1.docx
《IIR数字滤波器设计及软件实现1.docx》由会员分享,可在线阅读,更多相关《IIR数字滤波器设计及软件实现1.docx(19页珍藏版)》请在冰点文库上搜索。
![IIR数字滤波器设计及软件实现1.docx](https://file1.bingdoc.com/fileroot1/2023-5/16/2ae211af-744a-4c92-9509-9a782d67da4b/2ae211af-744a-4c92-9509-9a782d67da4b1.gif)
IIR数字滤波器设计及软件实现1
实验四
functionst=mstg
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(2,1,1);
plot(t,st);grid;xlabel('t(s)');ylabel('s(t)');
axis([0Tp/4min(st)max(st)]);title('(a)s(t)的波形');
subplot(2,1,2);
stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b)s(t)的频谱');
axis([0Fs/501.2]);
xlabel('f(Hz)');ylabel('幅度');
functionst=mstg1
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;
fo1=fc1/10;
fc2=Fs/20;
fo2=fc2/10;
fc3=Fs/40;
fo3=fc3/10;
xt1=(2+cos(2*pi*fo1*t)).*cos(2*pi*fc1*t);
xt2=(2+cos(2*pi*fo2*t)).*cos(2*pi*fc2*t);
xt3=(2+cos(2*pi*fo3*t)).*cos(2*pi*fc3*t);
st=xt1+xt2+xt3;
fxt=fft(st,N);
subplot(2,1,1);
plot(t,st);grid;xlabel('t(s)');ylabel('s(t)');
axis([0Tp/4min(st)max(st)]);title('(a)s(t)的波形');
subplot(2,1,2);
stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b)s(t)的频谱');
axis([0Fs/501.2]);
xlabel('f(Hz)');ylabel('幅度');
Fa=10000;T=1/Fs;
st=mstg;
fp=280;fs=450;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y1t=filter(B,A,st);
figure
(2)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y1t)-1;t=n*T;
plot(t,y1t);
xlabel('t(s)');ylabel('y1(t)');
title('低通滤波器分离出的信号y1(t)');
axis([00.08-1.51.5]);
fpl=440;fpu=560;fsl=275;fsu=900;
wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y2t=filter(B,A,st);
figure(3)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y2t)-1;t=n*T;
plot(t,y2t);
xlabel('t(s)');ylabel('y2(t)');
title('带通滤波器分离出的信号y2(t)');
axis([00.08-1.51.5]);
fp=890;fs=600;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo,'high');
y3t=filter(B,A,st);
figure(4)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y3t)-1;t=n*T;
plot(t,y3t);
xlabel('t(s)');ylabel('y3(t)');
title('高通滤波器分离出的信号y3(t)');
axis([00.08-1.51.5]);
Fs=10000;T=1/Fs;
st=mstg1;
fp=280;fs=450;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y1t=filter(B,A,st);
figure
(2)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y1t)-1;t=n*T;
plot(t,y1t);
xlabel('t(s)');ylabel('y1(t)');
title('低通滤波器分离出的信号y1(t)');
axis([00.08-33]);
fpl=440;fpu=560;fsl=275;fsu=900;
wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y2t=filter(B,A,st);
figure(3)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y2t)-1;t=n*T;
plot(t,y2t);
xlabel('t(s)');ylabel('y2(t)');
title('带通滤波器分离出的信号y2(t)');
axis([00.08-33]);
fp=890;fs=600;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo,'high');
y3t=filter(B,A,st);
figure(4)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y3t)-1;t=n*T;
plot(t,y3t);
xlabel('t(s)');ylabel('y3(t)');
title('高通滤波器分离出的信号y3(t)');
axis([00.08-33]);
改的
Fs=10000;T=1/Fs;
st=mstg1;
fp=280;fs=450;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y1t=filter(B,A,st);
figure
(2)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y1t)-1;t=n*T;
plot(t,y1t);
xlabel('t(s)');ylabel('y1(t)');
title('低通滤波器分离出的信号y1(t)');
axis([00.08-55]);
fpl=440;fpu=560;fsl=275;fsu=900;
wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo);
y2t=filter(B,A,st);
figure(3)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y2t)-1;t=n*T;
plot(t,y2t);
xlabel('t(s)');ylabel('y2(t)');
title('带通滤波器分离出的信号y2(t)');
axis([00.08-55]);
fp=890;fs=600;
wp=2*fp/Fs;ws=2*fs/Fs;Rp=0.1;As=60;
[N,wpo]=ellipord(wp,ws,Rp,As);
[B,A]=ellip(N,Rp,As,wpo,'high');
y3t=filter(B,A,st);
figure(4)
subplot(2,1,1);
[H,W]=freqz(B,A,1000);
k=abs(H);
plot(W/pi,20*log10(k/max(k)));gridon;
xlabel('w/pi');ylabel('幅度(dB)');
axis([01-805]);title('损耗函数曲线');
subplot(2,1,2);
n=0:
length(y3t)-1;t=n*T;
plot(t,y3t);
xlabel('t(s)');ylabel('y3(t)');
title('高通滤波器分离出的信号y3(t)');
axis([00.08-55]);
functionst=mstg1
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;
fo1=fc1/10;
fc2=Fs/20;
fo2=fc2/10;
fc3=Fs/40;
fo3=fc3/10;
xt1=(3+2*cos(2*pi*fo1*t)).*cos(2*pi*fc1*t);
xt2=(3+2*cos(2*pi*fo2*t)).*cos(2*pi*fc2*t);
xt3=(3+2*cos(2*pi*fo3*t)).*cos(2*pi*fc3*t);
st=xt1+xt2+xt3;
fxt=fft(st,N);
subplot(2,1,1);
plot(t,st);grid;xlabel('t(s)');ylabel('s(t)');
axis([0Tp/4min(st)max(st)]);title('(a)s(t)的波形');
subplot(2,1,2);
stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b)s(t)的频谱');
axis([0Fs/501.2]);
xlabel('f(Hz)');ylabel('幅度');