实验四:IIR数字滤波器设计及软件实现.doc
文本预览下载声明
实验四:IIR数字滤波器设计及软件实现
原信号函数
(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)μ?D?);
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)输出波形
高通滤波器
(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)μ?2¨D?)
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)μ?2¨D?)
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)μ?2¨D?)
subplot(2,1,2);
stem(f,abs(fyt)/max(abs(fyt)),.);grid;title((b
显示全部