您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 实验六数字滤波器设计
实验六数字滤波器设计13通信工程方鹏豪1341737081)基于Butterworth模拟滤波器原型,使用双线性变换法分别设计IIR数字低通滤波器,参数指标:通带截止频率Wp=0.2π,通带波动值Rp=1dB,阻带截止频率Ws=0.3π,阻带最小衰减Rs=20dB。滤波器采样频率Fs=2000Hz。要求:绘出幅频特性、相频特性图并比较结果,绘出滤波器零极点图,写出滤波器的系统函数。代码:%数字滤波器指标Wp=0.2*pi;Ws=0.3*pi;Rp=1;Rs=20;%转换为模拟滤波器指标Fs=2000;T=1/Fs;Omgp=(2/T)*tan(Wp/2);%双线性变换法中频率预畸变Omgs=(2/T)*tan(Ws/2);%模拟原型滤波器计算[N,Omgc]=buttord(Omgp,Omgs,Rp,Rs,'s')%计算阶数和截止频率[z0,p0,k0]=buttap(N);%归一化原型设计b0=k0*real(poly(z0))%求原型滤波器分子分母系数a0=real(poly(p0));[b,a]=lp2lp(b0,a0,Omgc)%变换为模拟滤波器分子分母系数%用双线性变换法计算数字滤波器系数[num,den]=bilinear(b,a,Fs)%数字滤波器设计结果%方法2:直接求模拟滤波器系数[b,a]=butter(N,Omgc,'s');[num,den]=bilinear(b,a,Fs);%方法3:直接求数字滤波器系数[N,Wc]=buttord(Wp/pi,Ws/pi,Rp,Rs);[num,den]=butter(N,Wc);%求数字滤波器的频率特性[H,w]=freqz(num,den);db_H=20*log10((abs(H)+eps)/max(abs(H)));%转换为分贝值subplot(2,2,1);plot(w/pi,abs(H));ylabel('幅度');xlabel('频率');title('幅度响应');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,1]);ripple=10^(-Rp/20);rs=10^(-Rs/20);set(gca,'YTickMode','manual','YTick',[0,rs,ripple,1]);gridsubplot(2,2,2);plot(w/pi,angle(H)/pi);ylabel('相位');xlabel('频率');title('相位响应');axis([0,1,-1,1]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,1]);set(gca,'YTickMode','manual','YTick',[-1,0,1]);gridsubplot(2,2,3);plot(w/pi,db_H);ylabel('幅度(dB)');xlabel('频率');title('幅度响应(dB)');axis([0,1,-50,5]);set(gca,'XTickMode','manual','XTick',[0,0.2,0.3,1]);set(gca,'YTickMode','manual','YTick',[-50,-20,-1,0]);gridsubplot(2,2,4);zplane(num,den);axis([-1.1,1.1,-1.1,1.1]);title('零极点图');运算图形结果:2)基于切比雪夫I型模拟滤波器原型设计,使用脉冲响应不变法设计一个IIR数字带通滤波器,参数指标:下通带截止频率Wp1=0.3π,上通带截止频率Wp2=0.7π,通带最大衰减Rp=1dB;下阻带截止频率Ws1=0.2π,上阻带截止频率Ws2=0.8π,阻带最小衰减Rs=20dB。滤波器采样频率Fs=2000Hz。要求:绘出幅频特性、相频特性图并比较结果,绘出滤波器零极点图,写出滤波器的系统函数。代码:%数字滤波器指标Wp1=0.3*pi;Wp2=0.7*pi;Ws1=0.2*pi;Ws2=0.8*pi;Rp=1;Rs=20;%转换为模拟滤波器指标Fs=2000;T=1/Fs;Omgp1=Wp1*Fs;Omgp2=Wp2*Fs;Omgs1=Ws1*Fs;Omgs2=Ws2*Fs;Omgp=[Omgp1,Omgp2];Omgs=[Omgs1,Omgs2];bw=Omgp2-Omgp1;w0=sqrt(Omgp1*Omgp2);%通带中心频率%模拟原型滤波器计算[N,Omgn]=cheb1ord(Omgp,Omgs,Rp,Rs,'s');%计算阶数和截止频率[z0,p0,k0]=cheb1ap(N,Rp);%归一化原型设计[b0,a0]=zp2tf(z0,p0,k0);%求原型滤波器系数[ba,aa]=lp2bp(b0,a0,w0,bw);%低通原型转换为带通[num,den]=impinvar(ba,aa,Fs);%用冲激响应不变法计算数字滤波器系数%求数字滤波器的频率特性[H,w]=freqz(num,den);db_H=20*log10((abs(H)+eps)/max(abs(H)));%转换为分贝值subplot(2,2,1);plot(w/pi,abs(H));ylabel('幅度');xlabel('频率');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);ripple=10^(-Rp/20);rs=10^(-Rs/20);set(gca,'YTickMode','manual','YTick',[0,rs,ripple,1]);gridsubplot(2,2,2);plot(w/pi,angle(H)/pi);ylabel('相位');xlabel('频率');axis([0,1,-1,1]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-1,0,1]);gridsubplot(2,2,3);plot(w/pi,db_H);ylabel('幅度(dB)');xlabel('频率');axis([0,1,-50,5]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-50,-20,-1,0]);gridsubplot(2,2,4);zplane(num,den);axis([-1.1,1.1,-1.1,1.1]);title('零极点图');图形结果:3)基于切比雪夫II型模拟滤波器原型设计,采用双线性变换法设计一个数字带阻滤波器,参数指标:通带低端截止频率Wp1=0.2π,通带高端截止频率Wp2=0.8π,通带最大衰减Rp=1dB;阻带低端截止频率Ws1=0.3π,阻带高端截止频率Ws2=0.7π,阻带最小衰减Rs=20dB。滤波器采样频率Fs=2000Hz。要求:绘出幅频特性、相频特性图并比较结果,绘出滤波器零极点图,写出滤波器的系统函数。代码如下:%数字滤波器指标Wp1=0.2*pi;Wp2=0.8*pi;Ws1=0.3*pi;Ws2=0.7*pi;Rp=1;Rs=20;%转换为模拟滤波器指标Fs=2000;T=1/Fs;Omgp1=(2/T)*tan(Wp1/2);Omgp2=(2/T)*tan(Wp2/2);Omgs1=(2/T)*tan(Ws1/2);Omgs2=(2/T)*tan(Ws2/2);Omgp=[Omgp1,Omgp2];Omgs=[Omgs1,Omgs2];bw=Omgp2-Omgp1;w0=sqrt(Omgp1*Omgp2);%阻带中心频率%模拟原型滤波器设计[N,Omgn]=cheb2ord(Omgp,Omgs,Rp,Rs,'s');%计算阶数和截止频率[z0,p0,k0]=cheb2ap(N,Rs);%归一化原型设计[b0,a0]=zp2tf(z0,p0,k0);%求原型滤波器系数[ba,aa]=lp2bs(b0,a0,w0,bw);%低通原型转换为带阻[num,den]=bilinear(ba,aa,Fs);%用双线性变换法计算数字滤波器系数%求数字滤波器的频率特性[H,w]=freqz(num,den);db_H=20*log10((abs(H)+eps)/max(abs(H)));%转换为分贝值subplot(2,2,1);plot(w/pi,abs(H));ylabel('幅度');xlabel('频率');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);ripple=10^(-Rp/20);rs=10^(-Rs/20);set(gca,'YTickMode','manual','YTick',[0,rs,ripple,1]);gridsubplot(2,2,2);plot(w/pi,angle(H)/pi*180,'k');ylabel('相位');xlabel('频率');axis([0,1,-180,180]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-180,-90,0,90,180]);gridsubplot(2,2,3);plot(w/pi,db_H);ylabel('幅度(dB)');xlabel('频率');axis([0,1,-60,5]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);set(gca,'YTickMode','manual','YTick',[-80,-20,-1,0]);gridsubplot(2,2,4);zplane(num,den);axis([-1.1,1.1,-1.1,1.1]);title('零极点图');图形结果:4)基于椭圆模拟滤波器原型设计,采用双线性变换法设计一个数字高通滤波器,参数指标:通带截止频率Wp=0.45π,通带最大衰减Rp=1dB;阻带截止频率Ws=0.3π,阻带最小衰减Rs=40dB。滤波器采样频率Fs=2000Hz。要求:绘出幅频特性、相频特性图并比较结果,绘出滤波器零极点图,写出滤波器的系统函数。代码如下:%数字滤波器指标Wp=0.45*pi;Ws=0.3*pi;Rp=1;Rs=40;%转换为模拟滤波器指标Fs=2000;T=1/Fs;Omgp=(2/T)*tan(Wp/2);Omgs=(2/T)*tan(Ws/2);%模拟原型滤波器设计[N,Omgc]=ellipord(Omgp,Omgs,Rp,Rs,'s');[z0,p0,k0]=ellipap(N,Rp,Rs);[b0,a0]=zp2tf(z0,p0,k0);[ba,aa]=lp2hp(b0,a0,Omgc);%低通原型转换为高通[num,den]=bilinear(ba,aa,Fs);%求数字滤波器的频率特性[H,w]=freqz(num,den);db_H=20*log10((abs(H)+eps)/max(abs(H)));%转换为分贝值subplot(2,2,1);plot(w/pi,abs(H));ylabel('幅度');xlabel('频率');axis([0,1,0,1.1]);set(gca,'XTickMode','manual','XTick',[0.2,0.3,0.7,0.8]);ripple=10^(-Rp/20);r
本文标题:实验六数字滤波器设计
链接地址:https://www.777doc.com/doc-2459347 .html