我正在研究在Matlab中设计IIR滤波器的代码。 “ Hs”的系数以有理格式显示。我希望改为以十进制格式显示系数。请让我知道我该怎么做。这是我的代码-
clc
clear all
syms s
A1= 0.8;
A2= 0.2;
Wap= 0.2*pi;
Was= 0.6*pi;
T=2;
Wdp=(2*tan(Wap/2))/T;
Wds=(2*tan(Was/2))/T;
n1= (1/A1^2)-1;
n2=(1/A2^2)-1;
N_num = log10(n2/n1);
N_den = log10(Wds/Wdp);
N=ceil(0.5* N_num/N_den)
Wc= Wdp/(n1^(1/(2*N)))
Hs=1;
if N%2==0
for k=1:N/2
bk= 2*sin((2*k-1)*pi/(2*N));
Hs=Hs.*((Wc^2)/(s^2 + (bk*Wc*s) + (Wc^2)));
end
end
if N%2!=0
for k=1:(N-1)/2
bk= 2*sin((2*k-1)*pi/(2*N));
Hs=Hs.*((Wc^2)/(s^2 + (bk*Wc*s) + (Wc^2)));
end
Hs=Hs./(s + Wc);
end
Hs
N =
2
Wc =
0.3752
Hs =
1267887102061961 /(9007199254740992 *(s + 3379365585548301/9007199254740992)*(s ^ 2 +(4779144643299303 * s)/ 9007199254740992 + 1267887102061961/9007199254740992))
我希望输出格式为-
N =
2
Wc =
0.3752
小时= 0.1408 /(s ^ 2 + 0.5306 * s + 0.1408) (该系数的值等于上述结果中的相应有理值)