第6章-无限脉冲响应数字滤波器设计
- 格式:doc
- 大小:175.50 KB
- 文档页数:12
《数字信号处理》作业与上机实验(第六章)班级: N电信12-1F学号: 24122201242姓名:曹福利任课老师:李宏民完成时间: 11.16信息与通信工程学院2013—2014学年第2 学期第6章 无限脉冲响应数字滤波器设计1、教材p195:13,14,15,16,17,18,192、某信号()x t 为:123()0.5cos(2)0.7cos(20.1)0.4cos(2)x t f t f t f t ππππ=+++,其中121100,130,600.f Hz f Hz f Hz ===设计最低阶数IIR 数字滤波器,按下图所示对()x t 进行数字滤波处理,实现:IIR 数字滤波器()x n ()y n A/D(周期T 采样)D/A(周期T)()x t ()y t1)将3f 频率分量以高于50dB 的衰减抑制,同时以低于2dB 的衰减通过1f 和2f 频率分量;2)将1f 和2f 频率分量以高于50dB 的衰减抑制,同时以低于2dB 的衰减通过3f 频率分量;要求:按数字滤波器直接型与级联型结构图编写滤波程序,求得()y n ;IIR滤波器采用双线性(高通)与冲击响应不变法(低通)设计;画出所设计的滤波器频率特性图、信号时域图;给出滤波器设计的MATLAB 代码与滤波器实现的代码;选择合适的信号采样周期T 与两种滤波器设计方法中对模拟滤波器冲击响应的采样周期T ’, 注意区分二者的异同。
1、13 . 解:t=1;fs=4000; wpu=0.45*pi; wpl=0.25*pi; wsu=0.55*pi; wsl=0.15*pi; wpz=[0.25,0.45]; wsz=[0.15,0.55]; wp=2/t*tan(wpz/2); ws=2/t*tan(wsz/2); rp=3; as=40;[n,wc]=buttord(wp,ws,rp,as,'s'); [b,a]=butter(n,wc,'s'); [bz,az]=impinvar(b,a,fs); [nd,wdc]=buttord(wpz,wsz,rp,as); [bd,adz]=butter(nd,wdc); hk=freqz(bd,adz); plot(abs(hk))01002003004005006000.20.40.60.811.21.4图一.Hzt=1; fs=4000; wpu=0.45*pi; wpl=0.25*pi; wsu=0.55*pi; wsl=0.15*pi; wpz=[0.25,0.45];wsz=[0.15,0.55]; wp=2/t*tan(wpz/2); ws=2/t*tan(wsz/2); rp=3; as=40;[n,wc]=buttord(wp,ws,rp,as,'s'); [b,a]=butter(n,wc,'s'); [bz,az]=impinvar(b,a,fs); [nd,wdc]=buttord(wpz,wsz,rp,as); [bd,adz]=butter(nd,wdc); hk=freqz(bd,adz); figure(1) plot(angle(hk)) figure(2)[hp,w]=freqz(bd,adz,4000); plot(w/pi,20*log10(hp));0100200300400500600-4-3-2-101234图二.相频特性曲线00.10.20.30.40.50.60.70.80.91-500-400-300-200-100100图三.损耗函数 14.解:T=1/80000;wp=4000*2*pi*T; ws=20000*2*pi*T; rp=0.5; rs=45;[n,wc]=buttord(wp,ws,rp,as,'s'); [b,a]=butter(n,wc,'s'); [bz,az]=impinvar(b,a); figure(1) freqz(b,a);[bz,az]=impinvar(b,a); figure(2) freqz(bz,az);0.10.20.30.40.50.60.70.80.91-400-300-200-1000Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-60-40-20020Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )0.10.20.30.40.50.60.70.80.91-800-600-400-2000Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s)00.10.20.30.40.50.60.70.80.91-40-30-20-10Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图四 15.解:T=1/80000;wp=4000*2*pi*T;ws=20000*2*pi*T; Rp=0.5; As=45;[N,wp1]=cheblord(wp,ws,Rp,As,'s'); [b,a]=chebyl(N,wp1,Rp,'s'); [bz,az]=impinvar(b,a,fs);[db,mag,pha,grd,w]=freqz_m(bz,az); plot(w/pi,db);0.10.20.30.40.50.60.70.80.91-800-600-400-2000Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-150-100-50050Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图五解:T=1/2500000;wp=325000*2*pi*T; ws=225000*2*pi*T; rp=1; rs=40;[N,wc]=ellipord(wp,ws,rp,rs); [b,a]=ellip(N,rp,rs,wc); figure(1) freqz(b,a);[bz,az]=impinvar(b,a); figure(2)freqz(bz,az);00.10.20.30.40.50.60.70.80.91-300-200-100Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-80-60-40-200Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )00.10.20.30.40.50.60.70.80.91-300-200-100Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-80-60-40-200Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图六解:fsl=560000; fsu=780000; fpl=375000; fpu=1000000; Fs=5000000;wp=[2*fsl/Fs,2*fsu/Fs]; ws=[2*fpl/Fs,2*fpu/Fs]; rp=0.5; rs=50;[N,wpo]=ellipord(wp,ws,rp,rs); [b,a]=ellip(N,rp,rs,wpo,'stop'); figure(1) freqz(b,a) figure(2)[bz,az]=impinvar(b,a); freqz(bz,az)0.10.20.30.40.50.60.70.80.91-400-2000200400Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-80-60-40-200Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )0.10.20.30.40.50.60.70.80.91010203040Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s)00.10.20.30.40.50.60.70.80.91-10-55Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图七解:fsl=500; fsu=2125; fpl=1050; fpu=1400; Fs=5000;wp=[2*fsl/Fs,2*fsu/Fs]; ws=[2*fpl/Fs,2*fpu/Fs]; rp=1; rs=40;[N,wpo]=ellipord(wp,ws,rp,rs); [b,a]=ellip(N,rp,rs,wpo,'stop'); figure(1) freqz(b,a) figure(2)[bz,az]=impinvar(b,a); freqz(bz,az)0.10.20.30.40.50.60.70.80.91-400-2000200400Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s)00.10.20.30.40.50.60.70.80.91-100-50Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )00.10.20.30.40.50.60.70.80.91100200300400Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s)00.10.20.30.40.50.60.70.80.91-60-40-20Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图八解:T=1/80000;wp=4000*2*pi*T; ws=20000*2*pi*T; rp=0.5; rs=45;[n,wc]=buttord(wp,ws,rp,as,'s'); [b,a]=butter(n,wc,'s'); [bz,az]=impinvar(b,a); figure(1) freqz(b,a);[bz,az]=impinvar(b,a); figure(2)freqz(bz,az);00.10.20.30.40.50.60.70.80.91-1000-500Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s )0.10.20.30.40.50.60.70.80.91-50-40-30-20-10Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )00.10.20.30.40.50.60.70.80.91-600-400-200Normalized Frequency (⨯π rad/sample)P h a s e (d e g r e e s)00.10.20.30.40.50.60.70.80.91-100-5050Normalized Frequency (⨯π rad/sample)M a g n i t u d e (d B )图九2、解:(1)代码为T=1/80000;Fs=3800;fp=130;fs=600;rs=50;wp=2*pi*fp/Fs;ws=2*pi*fs/Fs;Bt=ws-wp;alph=0.5842*(rs-21)^0.4+0.07886*(rs-21); N=ceil((rs-8)/2.285/Bt); wc=(wp+ws)/2/pi; hn=fir1(N,wc,kaiser(N+1,alph));M=1024;Hk=fft(hn,M);k=0:M/2-1;wk=(2*pi/M)*k;figure(1);plot(wk/pi,20*log10(abs(Hk(k+1))));axis([0,1,-80,5]);figure(2)plot(wk/pi,angle(Hk(k+1))/pi);00.10.20.30.40.50.60.70.80.91-80-70-60-50-40-30-20-10图11.损耗函数曲线00.10.20.30.40.50.60.70.80.91-1-0.8-0.6-0.4-0.20.20.40.60.81图12相频特性曲线(2)T=0.48;Fs=3800;fp=600;fs=100;wp=2*pi*fp/Fs;ws=2*pi*fs/Fs;atB=wp-ws;wc=wp;m=1;N=N+mod(N+1,2);Np=fix(wc/(2*pi/N));Ns=N-2*Np-1;Ak=[zeros(1,Np+1),ones(1,Ns),zeros(1,Np)]; Ak(Np+2)=T;Ak(N-Np)=T;thetak=-pi*(N-1)*(0:N-1)/N;Hk=Ak.*exp(1j*thetak);hn=real(ifft(Hk));M=1024;Hk=fft(hn,M);k=0:M/2-1;wk=(2*pi/M)*k;figure(2);plot(wk/pi,20*log10(abs(Hk(k+1))));axis([0,1,-80,5]);00.10.20.30.40.50.60.70.80.91-80-70-60-50-40-30-20-10图13.损耗函数00.10.20.30.40.50.60.70.80.91-1-0.8-0.6-0.4-0.20.20.40.60.81图14.相频曲线。
《数字信号处理》作业与上机实验
(第六章)
班级:
学号:
姓名:
任课老师:
完成时间: 2014.11.18
信息与通信工程学院
2013—2014学年第2 学期
第6章无限脉冲响应数字滤波器设计
1、教材p195:13,14,15,16,17,18,19
(1)代码如下:
clear;close all
t=1;fs=4000;
wpi=0.45*pi,wpl=0.25*pi;
wsu=0.55*pi,wsl=0.15*pi;
wpz=[0.25,0.45];
wsz=[0.15,0.55];
wp=2/t*tan(wpz/2);ws=2/t*tan(wsz/2);
rp=3;as=40;
[n,wc]=buttord(wp,ws,rp,as,'s');
[b,a]=butter(n,wc,'s');
[bz,az]=bilinear(b,a,fs);
[nd,wdc]=buttord(wpz,wsz,rp,as);
[bd,adz]=butter(nd,wdc);
hk=freqz(bd,adz)
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(bd,adz,4000);
figure(2)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.1
图1.1(2)代码如下:
fs=80000;T=1/fs;
rp=0.5;
rs=45;
wp=4000*2*pi*T;ws=20000*2*pi*T; [N,wc]=buttord(wp,ws,rp,rs,'s');
[B,A]=butter(N,wc,'s');
hk=freqz(B,A);
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(B,A);
figure(2)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.2
图1.2(3)代码如下:
fs=80000;T=1/fs;
rp=0.5;
rs=45;
wp=4000*2*pi*T;ws=20000*2*pi*T; [N,wc]=cheb1ord(wp,ws,rp,rs,'s');
[B,A]=cheby1(N,rp,wc,'s');
fk=0:120000:120000;wk=2*pi*fk
hk=freqs(B,A,wk);
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(B,A,4000);
[Bz,Az]=impinvar(B,A);
figure(2)
freqz(Bz,Az);图示如1.3
图1.3(4)代码如下:
fs=2500000;
T=1/fs;
rp=1;rs=40;
wp=325000*2*pi*T;ws=225000*2*pi*T; rp=1;rs=40;
[N,wpo]=ellipord(wp,ws,rp,rs);
[B,A]=ellip(N,rp,rs,wpo,'s')
hk=freqz(B,A)
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(B,A);
figure(2)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.4
图1.4
(5)代码如下:
fs=5000000;
T=1/fs;
rp=1;rs=50;
wp=[560000*2*pi*T,780000*2*pi*T];ws=[375000*2*pi*T,1000000*2*pi*T]; [N,wpo]=ellipord(wp,ws,rp,rs,'s');
[B,A]=ellip(N,rp,rs,wpo,'s')
hk=freqz(B,A)
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(B,A);
figure(2)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.5
图1.5
(6)代码如下:
fs=5000;
T=1/fs;
rp=1;rs=40;
wp=[500000*2*pi*T,2125000*2*pi*T;];ws=[1050000*2*pi*T,1400000*2*pi*T]; [N,wpo]=ellipord(wp,ws,rp,rs,'s');
[B,A]=ellip(N,rp,rs,wpo,'s');
hk=freqz(B,A)
figure(1)
plot(angle(hk))
title('相频特性曲线')
[hp,w]=freqz(B,A);
figure(2)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.6
图1.6 (7)代码如下:
fs=80000;T=1/fs;
rp=0.5;
rs=45;
wp=4000*2*pi*T;ws=20000*2*pi*T; [N,wc]=buttord(wp,ws,rp,rs,'s');
[B,A]=butter(N,wc,'s');
hk=freqz(B,A)
figure(1)
plot(angle(hk))
title('相频特性曲线')
[Bz,Az]=impinvar(B,A);
figure(2)
freqz(Bz,Az);
[hp,w]=freqz(Bz,Az);
figure(3)
plot(w/pi,20*log10(hp));
title('损耗函数曲线')
图示如1.7
图1.7
2、某信号()x t 为:123()0.5cos(2)0.7cos(20.1)0.4cos(2)x t f t f t f t ππππ=+++,其中121100,130,600.f Hz f Hz f Hz ===设计最低阶数IIR 数字滤波器,按下图所示对()x t 进行数字滤波处理,实现: IIR 数字滤波器()
x n ()y n A/D(周期T 采样)D/A(
周期
T)()x t ()y t
1)IIR 数字滤波器代码如下: fs=3800;T=1/fs
fp=130;fs=600;rs=50;
wp=2*pi*fp*T;ws=2*pi*fs*T;
Bt=ws-wp;
alph=0.5842*(rs-21)^0.4+0.07886*(rs-21); N=ceil((rs-8)/2.285/Bt);
wc=(wp+ws)/2/pi;
hn=fir1(N,wc,kaiser(N+1,alph));
M=1024;
Hk=fft(hn,M);
k=0:M/2-1;
wk=(2*pi/M)*k;
figure(1);
plot(wk/pi,20*log10(abs(Hk(k+1))));
title('损耗函数');grid on
figure(2)
plot(wk/pi,angle(Hk(k+1))/pi);grid on
title('相频特性曲线');
图示如2.1
图2.1。