一、实验目的 1.掌握巴特沃兹、切比雪夫Ⅰ、Ⅱ型和椭圆型模拟滤波器的特性和技术指标。 2.掌握用MATLAB 设计巴特沃兹、切比雪夫Ⅰ、Ⅱ型和椭圆型低通滤波器的方法。 二、实验原理 1.巴特沃兹低通数字滤波器幅度平方函数定义为
四、实验报告要求 1.简述实验目的及原理 2.整理好经过运行并证明是正确的实验程序并加上注释。绘出相应的图形。 3.比较各种常用的模拟原型滤波器的优缺点。选取原型滤波器的标准是什么?
代码语言:javascript复制op=0.2*pi;
rp=1;
os=0.3*pi;
as=16;
figure;
[b,a]=afd_butt(op,os,rp,as);
[H,w]=freqs(b,a);
h=impulse(b,a);
t=0:length(h)-1;
subplot(221),plot(w/(2*pi),abs(H));title('巴特幅频特性');xlabel('Hz');
subplot(222),plot(w/(2*pi),angle(H));title('巴特相频特性');xlabel('Hz');
subplot(223),plot(w/(2*pi),20*log10(abs(H)/max(abs(H))));title('巴特幅度分贝表示');xlabel('Hz');
subplot(224),plot(t,h);title('巴特单位冲激响应h(t)');xlabel('sec');
figure;
[b,a]=afd_chb1(op,os,rp,as);
[H,w]=freqs(b,a);
h=impulse(b,a);
t=0:length(h)-1;
subplot(221),plot(w/(2*pi),abs(H));title('切比1幅频特性');xlabel('Hz');
subplot(222),plot(w/(2*pi),angle(H));title('切比1相频特性');xlabel('Hz');
subplot(223),plot(w/(2*pi),20*log10(abs(H)/max(abs(H))));title('切比1幅度分贝表示');xlabel('Hz');
subplot(224),plot(t,h);title('切比1单位冲激响应h(t)');xlabel('sec');
figure;
[b,a]=afd_chb2(op,os,rp,as);
[H,w]=freqs(b,a);
h=impulse(b,a);
t=0:length(h)-1;
subplot(221),plot(w/(2*pi),abs(H));title('切比2幅频特性');xlabel('Hz');
subplot(222),plot(w/(2*pi),angle(H));title('切比2相频特性');xlabel('Hz');
subplot(223),plot(w/(2*pi),20*log10(abs(H)/max(abs(H))));title('切比2幅度分贝表示');xlabel('Hz');
subplot(224),plot(t,h);title('切比2单位冲激响应h(t)');xlabel('sec');
figure;
[b,a]=afd_elip(op,os,rp,as);
[H,w]=freqs(b,a);
h=impulse(b,a);
t=0:length(h)-1;
subplot(221),plot(w/(2*pi),abs(H));title('椭圆幅频特性');xlabel('Hz');
subplot(222),plot(w/(2*pi),angle(H));title('椭圆相频特性');xlabel('Hz');
subplot(223),plot(w/(2*pi),20*log10(abs(H)/max(abs(H))));title('椭圆幅度分贝表示');xlabel('Hz');
subplot(224),plot(t,h);title('椭圆单位冲激响应h(t)');xlabel('sec');
调用的函数:
(1)afd_butt.m
function [b,a]=afd_butt(Wp,Ws,Rp,As);
%Analog Lowpass Filter Design :Butterworth
%--------------------------------------------
%[b,a]=afd_butt(Wp,Ws,Rp,As);
%b=Numberator coefficients of Ha(s)
%a=Denominator coefficients of Ha(s)
%Wp=Passband edge frequency in rad/sec;Wp>0
%Ws=Stopband edge frequency in rad/sec;Ws>Wp>0
%Rp=Passband ripple in dB;(Rp>0)
%As=Stopband attenuation in dB;(As>0)
if Wp<=0
error('Passband edge must be larger than 0')
end
if Ws<=Wp
error('Stopband edge must be larger than Passband edge')
end
if (Rp<=0)|(As<0)
error('PB ripple and/or SB attenuation must be larger than 0')
end
N=ceil(log10((10^(Rp/10)-1)/(10^(As/10)))/(2*log10(Wp/Ws)));
fprintf('n***Butterworth Filter Order=%2.0fn',N)
OmegaC=Wp/((10^(Rp/10)-1)^(1/(2*N)));
[b,a]=u_buttap(N,OmegaC);
(2) afd_chb1.m
% Chebyshev I 型模拟低通滤波器原型设计;
% afd_chb1.m;
function [b a]=afd_chb1(Wp,Ws,Rp,As);
% Anolog Lowpass Filter Design:chebyshev-1
% ^^^^^^^^^^^^^^^^^^^
% [b a]=afd_chb1(Wp,Ws,Rp,As);
% b=numerator polynomial coefficients of Ha(s);
% a=denominator polynomial coefficients of Ha(s);
% Wp=passband edge frequency in rad/sec;Wp>0;
% Ws=stopband edge frequency in rad/sec;Ws>Wp>0;
% Rp=passband ripple in dB;(Rp>0);
% As=stopband attenuation in dB;(As>0);
% ^^^^^^^^^^^^^^^^^^^^
if Wp<=0
error('passband edge must be larger than 0')
end
if Ws<=Wp
error('stopband dege must be larger than passband edge')
end
if(Rp<=0)|(As<0)
error('PB ripple and/or SB attenuation must be larger than 0')
end
ep=sqrt(10^(Rp/10)-1);
A=10^(As/20);
OmegaC=Wp;
OmegaR=Ws/Wp;
g=sqrt(A*A-1)/ep;
N=ceil(log10(g sqrt(g*g-1))/log10(OmegaR sqrt(OmegaR*OmegaR-1)));
fprintf('n***Chebyshev-1 filter order=%2.0fn',N)
[b a]=u_chblap(N,Rp,OmegaC);
(3) afd_chb2.m
% Chebyshev II 型模拟低通滤波器原型设计;
% afd_chb2.m;
function [b a]=afd_chb2(Wp,Ws,Rp,As);
% Anolog Lowpass Filter Design:chebyshev-2
% ^^^^^^^^^^^^^^^^^^^
% [b a]=afd_chb1(Wp,Ws,Rp,As);
% b=numerator polynomial coefficients of Ha(s);
% a=denominator polynomial coefficients of Ha(s);
% Wp=passband edge frequency in rad/sec;Wp>0;
% Ws=stopband edge frequency in rad/sec;Ws>Wp>0;
% Rp=passband ripple in dB;(Rp>0);
% As=stopband attenuation in dB;(As>0);
% ^^^^^^^^^^^^^^^^^^^^
if Wp<=0
error('passband edge must be larger than 0')
end
if Ws<=Wp
error('stopband dege must be larger than passband edge')
end
if(Rp<=0)|(As<0)
error('PB ripple and/or SB attenuation must be larger than 0')
end
ep=sqrt(10^(Rp/10)-1);
A=10^(As/20);
OmegaC=Wp;
OmegaR=Ws/Wp;
g=sqrt(A*A-1)/ep;
N=ceil(log10(g sqrt(g*g-1))/log10(OmegaR sqrt(OmegaR*OmegaR-1)));
fprintf('n***Chebyshev-1 filter order=%2.0fn',N)
[b,a]=u_chb2ap(N,As,OmegaC);
(4) afd_elip.m
%椭圆模拟低通滤波器原型设计
�d_elip.m
function [b a]=afd_elip(Wp,Ws,Rp,As);
%Anolog lowpass filter design:Elliptic
%^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%[b a]=afd_elip(Wp,Ws,Rp,As);
%b=Numberator coefficients of Ha(s)
% a=denominator polynomial coefficients of Ha(s);
% Wp=passband edge frequency in rad/sec;Wp>0;
% Ws=stopband edge frequency in rad/sec;Ws>Wp>0;
% Rp=passband ripple in dB;(Rp>0);
% As=stopband attenuation in dB;(As>0);
%%%%%%%%%%%%%%%%%%%%%%%%%
if Wp<=0
error('passband edge must be larger than 0')
end
if Ws<=Wp
error('stopband dege must be larger than passband edge')
end
if(Rp<=0)|(As<0)
error('PB ripple and/or SB attenuation must be larger than 0')
end
ep=sqrt(10^(Rp/10)-1);
A=10^(As/20);
OmegaC=Wp;
k=Wp/Ws;
k1=ep/sqrt(A*A-1);
capk=ellipke([k.^2 1-k.^2]);
capk1=ellipke([k1.^2 1-k1.^2]);
N=ceil(capk(1)*capk1(2)/(capk(2)*capk1(1)));
fprintf('n***Elliptic Filter Order=%2.0fn',N)
[b a]=u_elipap(N,Rp,As,OmegaC)