配色: 字号:
2010136102张秋红实验六
2012-06-29 | 阅:  转:  |  分享 
  
实验六

评分人:陈奇分数:9.3

一、实验目的

1.练习并掌握脉冲响应不变法设计IIR数字滤波器的方法;

2.练习并掌握双线性变换法设计IIR数字滤波器的方法;

二、实验原理与方法(同实验五)

[n,wn]=cheb1ord(wp,ws,Rp,Rs,’s’);

[n,wn]=cheb1ord(wp,ws,Rp,Rs);

[z,p,k]=cheb1ap(n,Rp);

[z,p,k]=cheb2ap(n,Rs);

[b,a]=cheby1(n,Rp,wn);

[b,a]=cheby2(n,Rs,wn);

[b,a]=cheby1(n,Rp,wn,’ftype’);

[b,a]=cheby2(n,Rs,wn,’ftype’);

[bz,p,k]=cheby1(n,Rp,wn);

[bz,p,k]=cheby2(n,Rs,wn);

[b,a]=cheby1(n,Rp,wn,’s’);

[b,a]=cheby2(n,Rs,wn,’s’);

[b,a]=cheby1(n,Rp,wn,’ftype’,’s’);

[b,a]=cheby2(n,Rs,wn,’ftype’,’s’);

三、实验内容及步骤

5.用Chebyshev-II实现实验内容1234的滤波器设计并与实验内容1234的结果进行对照,以了解Chebyshev-I/II的区别。

1)

切比雪夫I型

程序:

clear

clc

Wp=0.4pi;Ws=0.6pi;Rp=7;Rs=16;Fs=1000;%数字滤波器指标

%模拟滤波器设计

wp=WpFs;ws=WsFs;Rp=7;Rs=16;%模拟滤波器指标:w=ΩT->Ω=wFs

[n,Wn]=cheb1ord(wp,ws,Rp,Rs,''s'');%阶次估计

[z,p,k]=cheb1ap(n,Rp);%模拟低通原型

[b,a]=zp2tf(z,p,k);%零极点->直接

[b,a]=lp2lp(b,a,Wn);%低通->低通(去归一化)

[H,w]=freqs(b,a);

figure(1)

subplot(2,1,1),plot(w/2/pi,20log10(abs(H)));grid

xlabel(''Frequence(Hz)''),ylabel(''Magnitude(dB)'');

subplot(2,1,2),plot(w/2/pi,angle(H)/pi180);grid

xlabel(''Frequence(Hz)''),ylabel(''Phase(degress)'');

%冲激响应不变法设计数字滤波器

figure(2)

[bz,az]=impinvar(b,a,Fs);

freqz(bz,az,256);

%数字滤波器的直接设计

figure(3)

[n,wn]=cheb1ord(Wp/pi,Ws/pi,Rp,Rs)

[b,a]=cheby1(n,Rp,wn);

freqz(b,a,256);

图像:







切比雪夫II型

程序:

clear

clc

Wp=0.4pi;Ws=0.6pi;Rp=7;Rs=16;Fs=1000;%数字滤波器指标

%模拟滤波器设计

wp=WpFs;ws=WsFs;Rp=7;Rs=16;%模拟滤波器指标:w=ΩT->Ω=wFs

[n,Wn]=cheb2ord(wp,ws,Rp,Rs,''s'');%阶次估计

[z,p,k]=cheb2ap(n,Rp);%模拟低通原型

[b,a]=zp2tf(z,p,k);%零极点->直接

[b,a]=lp2lp(b,a,Wn);%低通->低通(去归一化)

[H,w]=freqs(b,a);

figure(1)

subplot(2,1,1),plot(w/2/pi,20log10(abs(H)));grid

xlabel(''Frequence(Hz)''),ylabel(''Magnitude(dB)'');

subplot(2,1,2),plot(w/2/pi,angle(H)/pi180);grid

xlabel(''Frequence(Hz)''),ylabel(''Phase(degress)'');

%冲激响应不变法设计数字滤波器

figure(2)

[bz,az]=impinvar(b,a,Fs);

freqz(bz,az,256);

%数字滤波器的直接设计

figure(3)

[n,wn]=cheb2ord(Wp/pi,Ws/pi,Rp,Rs)

[b,a]=cheby2(n,Rp,wn);

freqz(b,a,256);

图像:







2)

切比雪夫I型:

程序:

clear

clc

wp=.8pi;ws=.44pi;rp=3;rs=20;Fs=2000;

%Firstlytofinishfrequencyprewarping;

wap=2Fstan(wp/2);was=2Fstan(ws/2);

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);

[b,a]=zp2tf(z,p,k);

[bt,at]=lp2hp(b,a,wap);%低通->高通(去归一化)

w=0:pi:4000pi;

H=freqs(bt,at,w);

subplot(3,1,1),plot(w/2/pi,20log10(abs(H)));grid

title(''High-passAF'');

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz,az]=bilinear(bt,at,Fs);

[h,w]=freqz(bz,az,256,1);

Subplot(312);

plot(w,20log10(abs(h)));grid;

title(''High-passDF(1)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby1(n,rp,wp/pi,''high'');

[h1,w1]=freqz(b,a,256,1);

Subplot(313);

plot(w,20log10(abs(h1)));grid;title(''High-passDF(2)'');



图像:



切比雪夫II型

程序:

clear

clc

wp=.8pi;ws=.44pi;rp=3;rs=20;Fs=2000;

%Firstlytofinishfrequencyprewarping;

wap=2Fstan(wp/2);was=2Fstan(ws/2);

[n,wn]=cheb2ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb2ap(n,rp);

[b,a]=zp2tf(z,p,k);

[bt,at]=lp2hp(b,a,wap);%低通->高通(去归一化)

w=0:pi:4000pi;

H=freqs(bt,at,w);

subplot(3,1,1),plot(w/2/pi,20log10(abs(H)));grid

title(''High-passAF'');

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz,az]=bilinear(bt,at,Fs);

[h,w]=freqz(bz,az,256,1);

Subplot(312);

plot(w,20log10(abs(h)));grid;

title(''High-passDF(1)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb2ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby2(n,rp,wp/pi,''high'');

[h1,w1]=freqz(b,a,256,1);

Subplot(313);

plot(w,20log10(abs(h1)));grid;title(''High-passDF(2)'');



图像:



3)

切比雪夫I型

程序:

clear

clc

fp=[300400];fs=[200500];rp=3;rs=18;Fs=2000;%模拟技术指标

wp=fp2pi/Fs;ws=fs2pi/Fs;%数字技术指标

%模拟低通原型滤波器设计

wap=2Fstan(wp./2);was=2Fstan(ws./2);%预畸变

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);[bp,ap]=zp2tf(z,p,k);[h1,w1]=freqs(bp,ap);

Subplot(411);plot(w1,abs(h1));grid;title(''lowpassG(p)'')

%模拟低通原型->模拟带通滤波器

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bs,as]=lp2bp(bp,ap,w0,bw);

w2=0:pi:4000pi;

h2=freqs(bs,as,w2);

Subplot(412);plot(w2/2/pi,20log10(abs(h2)));grid;title(''bandpassH(p)'')

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz1,az1]=bilinear(bs,as,Fs);

[h3,w3]=freqz(bz1,az1,1024,Fs);

Subplot(413);plot(w3,20log10(abs(h3)));grid;title(''bandpassDFH1(z)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);[bz2,az2]=cheby1(n,rp,wp/pi,''bandpass'');

[h4,w4]=freqz(bz2,az2,1024,Fs);

Subplot(414);plot(w4,20log10(abs(h4)));grid;title(''BandpassDFH2(z)'');

图像:



切比雪夫II型

程序:

clear

clc

fp=[300400];fs=[200500];rp=3;rs=18;Fs=2000;%模拟技术指标

wp=fp2pi/Fs;ws=fs2pi/Fs;%数字技术指标

%模拟低通原型滤波器设计

wap=2Fstan(wp./2);was=2Fstan(ws./2);%预畸变

[n,wn]=cheb2ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb2ap(n,rp);[bp,ap]=zp2tf(z,p,k);[h1,w1]=freqs(bp,ap);

Subplot(411);plot(w1,abs(h1));grid;title(''lowpassG(p)'')

%模拟低通原型->模拟带通滤波器

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bs,as]=lp2bp(bp,ap,w0,bw);

w2=0:pi:4000pi;

h2=freqs(bs,as,w2);

Subplot(412);plot(w2/2/pi,20log10(abs(h2)));grid;title(''bandpassH(p)'')

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz1,az1]=bilinear(bs,as,Fs);

[h3,w3]=freqz(bz1,az1,1024,Fs);

Subplot(413);plot(w3,20log10(abs(h3)));grid;title(''bandpassDFH1(z)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb2ord(wp/pi,ws/pi,rp,rs);[bz2,az2]=cheby2(n,rp,wp/pi,''bandpass'');

[h4,w4]=freqz(bz2,az2,1024,Fs);

Subplot(414);plot(w4,20log10(abs(h4)));grid;title(''BandpassDFH2(z)'');

图像:



4)

切比雪夫I型

程序:

clear

clc

fp=[95105];fs=[99101];rp=3;rs=14;Fs=1000;

wp=fp2pi/Fs;ws=fs2pi/Fs;%wp=[.19pi0.21pi];ws=[.198pi0.202pi];

wap=2Fstan(wp./2);was=2Fstan(ws./2);%frequencyprewarping;

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);[b,a]=zp2tf(z,p,k);

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bt,at]=lp2bs(b,a,w0,bw);

[bz1,az1]=bilinear(bt,at,Fs);

[h,w]=freqz(bz1,az1,256,Fs);

Subplot(221);plot(w,20log10(abs(h)));

grid;title(''bandstopDFH1(z)'');

Subplot(223);plot(w,angle(h));grid;

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby1(n,rp,wp/pi,''stop'')

[h1,w1]=freqz(b,a,256,Fs);

Subplot(222);plot(w1,20log10(abs(h1)));

grid;title(''bandstopDFH2(z)'');

Subplot(224);plot(w,angle(h));grid;



图像:



切比雪夫II型

程序:

clear

clc

fp=[95105];fs=[99101];rp=3;rs=14;Fs=1000;

wp=fp2pi/Fs;ws=fs2pi/Fs;%wp=[.19pi0.21pi];ws=[.198pi0.202pi];

wap=2Fstan(wp./2);was=2Fstan(ws./2);%frequencyprewarping;

[n,wn]=cheb2ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb2ap(n,rp);[b,a]=zp2tf(z,p,k);

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bt,at]=lp2bs(b,a,w0,bw);

[bz1,az1]=bilinear(bt,at,Fs);

[h,w]=freqz(bz1,az1,256,Fs);

Subplot(221);plot(w,20log10(abs(h)));

grid;title(''bandstopDFH1(z)'');

Subplot(223);plot(w,angle(h));grid;

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb2ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby2(n,rp,wp/pi,''stop'')

[h1,w1]=freqz(b,a,256,Fs);

Subplot(222);plot(w1,20log10(abs(h1)));

grid;title(''bandstopDFH2(z)'');

Subplot(224);plot(w,angle(h));grid;

图像:









6.参照实验内容1234,设计如下指标的Chebyshev-I/II滤波器.画出模拟低通、模拟高通/带通/带阻、数字低通/高通/带通/带阻的幅频和相频特性图。

1)低通指标:wp=0.2π,rp=1dB,ws=0.3π,rs=16dB。

切比雪夫I型

程序:

clear

clc

Wp=0.2pi;Ws=0.3pi;Rp=1;Rs=16;Fs=1000;%数字滤波器指标

%模拟滤波器设计

wp=WpFs;ws=WsFs;Rp=7;Rs=16;%模拟滤波器指标:w=ΩT->Ω=wFs

[n,Wn]=cheb1ord(wp,ws,Rp,Rs,''s'');%阶次估计

[z,p,k]=cheb1ap(n,Rp);%模拟低通原型

[b,a]=zp2tf(z,p,k);%零极点->直接

[b,a]=lp2lp(b,a,Wn);%低通->低通(去归一化)

[H,w]=freqs(b,a);

figure(1)

subplot(2,1,1),plot(w/2/pi,20log10(abs(H)));grid

xlabel(''Frequence(Hz)''),ylabel(''Magnitude(dB)'');

subplot(2,1,2),plot(w/2/pi,angle(H)/pi180);grid

xlabel(''Frequence(Hz)''),ylabel(''Phase(degress)'');

%数字滤波器的直接设计

figure(2)

[n,wn]=cheb1ord(Wp/pi,Ws/pi,Rp,Rs)

[b,a]=cheby1(n,Rp,wn);

freqz(b,a,256);

图像:





结果:

n=

2

wn=

0.2000

切比雪夫II型

程序:

clear

clc

Wp=0.2pi;Ws=0.3pi;Rp=1;Rs=16;Fs=1000;%数字滤波器指标

%模拟滤波器设计

wp=WpFs;ws=WsFs;Rp=7;Rs=16;%模拟滤波器指标:w=ΩT->Ω=wFs

[n,Wn]=cheb2ord(wp,ws,Rp,Rs,''s'');%阶次估计

[z,p,k]=cheb2ap(n,Rp);%模拟低通原型

[b,a]=zp2tf(z,p,k);%零极点->直接

[b,a]=lp2lp(b,a,Wn);%低通->低通(去归一化)

[H,w]=freqs(b,a);

figure(1)

subplot(2,1,1),plot(w/2/pi,20log10(abs(H)));grid

xlabel(''Frequence(Hz)''),ylabel(''Magnitude(dB)'');

subplot(2,1,2),plot(w/2/pi,angle(H)/pi180);grid

xlabel(''Frequence(Hz)''),ylabel(''Phase(degress)'');

%数字滤波器的直接设计

figure(2)

[n,wn]=cheb2ord(Wp/pi,Ws/pi,Rp,Rs)

[b,a]=cheby2(n,Rp,wn);

freqz(b,a,256);

图像:





结果:

n=

2

wn=

0.3000

2)高通指标:wp=0.3π,rp=1dB,ws=0.2π,rs=30dB。

切比雪夫I型

程序:

clear

clc

wp=.3pi;ws=.2pi;rp=1;rs=30;Fs=2000;

%Firstlytofinishfrequencyprewarping;

wap=2Fstan(wp/2);was=2Fstan(ws/2);

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);

[b,a]=zp2tf(z,p,k);

[bt,at]=lp2hp(b,a,wap);%低通->高通(去归一化)

w=0:pi:4000pi;

H=freqs(bt,at,w);

subplot(3,1,1),plot(w/2/pi,20log10(abs(H)));grid

title(''High-passAF'');

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz,az]=bilinear(bt,at,Fs);

[h,w]=freqz(bz,az,256,1);

Subplot(312);

plot(w,20log10(abs(h)));grid;

title(''High-passDF(1)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby1(n,rp,wp/pi,''high'');

[h1,w1]=freqz(b,a,256,1);

Subplot(313);

plot(w,20log10(abs(h1)));grid;title(''High-passDF(2)'');

图像:





3)带通指标:

wp=[0.3π0.5π],rp=1dB,ws=[0.20.6],rs=30dB。

切比雪夫I型

程序:

clear

clc

fp=[300500];fs=[200600];rp=1;rs=30;Fs=2000;%模拟技术指标

wp=fp2pi/Fs;ws=fs2pi/Fs;%数字技术指标

%模拟低通原型滤波器设计

wap=2Fstan(wp./2);was=2Fstan(ws./2);%预畸变

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);[bp,ap]=zp2tf(z,p,k);[h1,w1]=freqs(bp,ap);

Subplot(411);plot(w1,abs(h1));grid;title(''lowpassG(p)'')

%模拟低通原型->模拟带通滤波器

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bs,as]=lp2bp(bp,ap,w0,bw);

w2=0:pi:4000pi;

h2=freqs(bs,as,w2);

Subplot(412);plot(w2/2/pi,20log10(abs(h2)));grid;title(''bandpassH(p)'')

%双线性变换法设计数字滤波器

%Note:s=(2/T)(z-1)/(z+1);T=1,thatis2Fs=1,Fs=0.5;

[bz1,az1]=bilinear(bs,as,Fs);

[h3,w3]=freqz(bz1,az1,1024,Fs);

Subplot(413);plot(w3,20log10(abs(h3)));grid;title(''bandpassDFH1(z)'');

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);[bz2,az2]=cheby1(n,rp,wp/pi,''bandpass'');

[h4,w4]=freqz(bz2,az2,1024,Fs);

Subplot(414);plot(w4,20log10(abs(h4)));grid;title(''BandpassDFH2(z)'');

图像:





4)带阻指标:

wp=[0.2π0.6π],rp=1dB,ws=[0.30.5],rs=30dB。

切比雪夫I型

程序:

clear

clc

fp=[100300];fs=[150250];rp=1;rs=30;Fs=1000;

wp=fp2pi/Fs;ws=fs2pi/Fs;%wp=[.19pi0.21pi];ws=[.198pi0.202pi];

wap=2Fstan(wp./2);was=2Fstan(ws./2);%frequencyprewarping;

[n,wn]=cheb1ord(wap,was,rp,rs,''s'');

[z,p,k]=cheb1ap(n,rp);[b,a]=zp2tf(z,p,k);

bw=wap(2)-wap(1);w0=sqrt(wap(1)wap(2));

[bt,at]=lp2bs(b,a,w0,bw);

[bz1,az1]=bilinear(bt,at,Fs);

[h,w]=freqz(bz1,az1,256,Fs);

Subplot(221);plot(w,20log10(abs(h)));

grid;title(''bandstopDFH1(z)'');

Subplot(223);plot(w,angle(h));grid;

%DirectlytodesignH(z)bybutter.m

[n,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);

[b,a]=cheby1(n,rp,wp/pi,''stop'')

[h1,w1]=freqz(b,a,256,Fs);

Subplot(222);plot(w1,20log10(abs(h1)));

grid;title(''bandstopDFH2(z)'');

Subplot(224);plot(w,angle(h));grid;



图像:



结果:

b=

Columns1through5

0.1103-0.33710.8276-1.20811.4721

Columns6through9

-1.20810.8276-0.33710.1103

a=

Columns1through5

1.0000-1.58551.2098-1.11611.3109

Columns6through9

-0.54160.0485-0.22420.1872

总结:

IIR滤波器的设计步骤1)确定数字滤波器的技术指标:通带截止频率ωp(ωl?、ωu)、阻带截止频率ωs(ωs1?、?ωs2)通带衰减αp?、阻带衰减αs。2)?将数字滤波器的技术指标转换成模拟滤波器的技术指标。脉冲响应不变法:?双线性变换法:3)?将模拟滤波器的技术指标转成模拟低通滤波器的技术指标:频率变换4)?设计归一化低通滤波器Ga(p)?。5)?将Ga(p)转成模拟滤波器Ha(s):去归一化?+?频率变换6)?将模拟滤波器Ha(s),从s平面转换到z平面,得到数字滤波器系统函数H(z),脉冲响应不变法或双线性变换法。

献花(0)
+1
(本文系依米荷阳首藏)