利用MATLAB结合双线性变换法设计一个数字切比雪夫带通IIR滤波器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用MATLAB结合双线性变换法设计一个数字切比雪夫带通IIR滤波器相关的知识,希望对你有一定的参考价值。
要做一个上面题目的课程设计,各位大虾帮帮忙,到底怎么做,看了很多资料,现在心里一片混乱。
我们还没有学习dsp,学校就让我们做这,郁闷!
通带频率0.2*pi,截止频率0.3*pi通带衰减波纹比1dB,阻带衰减15dB
>> wp=0.2*pi;
>> ws=0.3*pi;
>> Rp=1;
>> As=15;
>> T=1;Fs=1/T;
>> OmegaP=(2/T)*tan(wp/2);
>> OmegaS=(2/T)*tan(ws/2);
>> [cs,ds]=afd_chb1(OmegaP,OmegaS,Rp,As);
*** Chebyshev-1 Filter Order= 4
>> [b,a]=bilinear(cs,ds,Fs);%双线性变换
>> [C,B,A]=dir2cas(b,a)
当然先得加上2个M函数,是频带变换的
函数1
function [b,a]=afd_chb1(Wp,Ws,Rp,As);
% Analog Lowpass Filter Design:Chebyshen-1
%----------------------------------------------
% [b,a]=afd_chb1(Wp,Ws,Rp,As);
% b=Numerator 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 large 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
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.0f\n',N)
[b,a]=u_chb1ap(N,Rp,OmegaC);
函数2
function [b0,B,A]=dir2cas(b,a)
% DIRECT-form to CASCADE-foem conversion(cplxpair version)
%--------------------------------------------------------------------
%[b0,B,A]=dir2cas(b,a)
%b0=gain coefficient
%B=K by 3 matrix of real coefficients containing bk's
%A=K by 3 matrix of real coefficients containing ak's
%b=numerator polynonial coefficients of DIRECT form
%a=denominator polynomial coefficients of DIRECT form
%compute gain coefficient b0
b0=b(1);b=b/b0;
a0=a(1);a=a/a0;
b0=b0/a0;
%
M=length(b);N=length(a);
if N>M
b=[b zeros(1,N-M)];
elseif M>N
a=[a zeros(1,M-N)];N=M;
else
NM=0;
end
%
K=floor(N/2);B=zeros(K,3);A=zeros(K,3);
if K*2==N;
b=[b 0];
a=[a 0];
end
%
broots=cplxpair(roots(b));
aroots=cplxpair(roots(a));
for i=1:2:2*K
Brow=broots(i:1:i+1,:);
Brow=real(poly(Brow));
B(fix((i+1)/2),:)=Brow;
Arow=aroots(i:1:i+1,:);
Arow=real(poly(Arow));
A(fix((i+1)/2),:)=Arow;
end 参考技术A 通带频率0.2*pi,截止频率0.3*pi通带衰减波纹比1dB,阻带衰减15dB
>> wp=0.2*pi;
>> ws=0.3*pi;
>> Rp=1;
>> As=15;
>> T=1;Fs=1/T;
>> OmegaP=(2/T)*tan(wp/2);
>> OmegaS=(2/T)*tan(ws/2);
>> [cs,ds]=afd_chb1(OmegaP,OmegaS,Rp,As);
*** Chebyshev-1 Filter Order= 4
>> [b,a]=bilinear(cs,ds,Fs);%双线性变换
>> [C,B,A]=dir2cas(b,a)
当然先得加上2个M函数,是频带变换的
函数1
function [b,a]=afd_chb1(Wp,Ws,Rp,As);
% Analog Lowpass Filter Design:Chebyshen-1
%----------------------------------------------
% [b,a]=afd_chb1(Wp,Ws,Rp,As);
% b=Numerator 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 large than 0')
end 参考技术B fp1=? 通带截止频率1自己设;单位Hz
fs1=?阻带截止频率1自己设;单位Hz
fp2=? 通带截止频率2自己设;单位Hz
fs2=?阻带截止频率2自己设;单位Hz
Fs=?抽样频率自己设;单位Hz
rp=?通带衰减自己设;单位db
rs=?阻带衰减自己设;单位db
wp1=2*fp1/Fs;
ws1=2*fs1/Fs;
wp2=2*fp2/Fs;
ws2=2*fs2/Fs;
[n,wn]=cheb1ord([wp1 wp2],[ws1 ws2],rp,rs);
[bz,az]=cheby1(n,rp,wn);
freqz(bz,az,512,Fs);
以上是关于利用MATLAB结合双线性变换法设计一个数字切比雪夫带通IIR滤波器的主要内容,如果未能解决你的问题,请参考以下文章