A*s^4 + B*s^3 + C*s^2 D*s + E
/
F*s^5 + G*s^4+ H*s^3 + I*s^2 + J*s + 1
=
=1/(c5*s + 1/(r5 + 1/(c4*s + 1/(r4 +1/(1/(r3 + 1/(c2*s + 1/(r2 + 1/(c1*s
+ 1/r1)))) + c3*s)))))
1
= ---------------------------------------------------------
1
c5s + --------------------------------------------------
1
r5 + ---------------------------------------------
1
c4 s +--------------------------------------
1
r4 + ---------------------------------
1
c3 s + --------------------------
1
r3 +---------------------
1
c2 s +--------------
1
r2 +---------
1
c1 s+ --
r1
用的辗转相除的办法,可如附图算出结果。
![矩阵里面取数值相除消掉最高次项后赋值另一个矩阵怎么可以没有余项]()
并且自己学习写了一段,然后发现
输入N和D =
format longg
N = [1709000 5505000 1632000 47000 144.99]
D = [1 36393000 14591000 779000 8043.2 4.506]
>> fostertocauerdiode5(N,D)
结果从r5那个值开始,后面的项就消不掉了,可是还是要继续算,好纠结。。。
后来发现从第一次想要减去最高次项的式子里,因为matlab里面除法得到的商再乘以除数,被被除数减完还有剩余的最高此项Z(1,:)=U(1,:)-M(1,:).*w(1);
但是我尝试了从第二次项赋值,还是得不到正确的第二次辗转相除的结果,求问我这个赋值有什么问题?谢谢!
现在只需要先写五阶的式子,如果有大神可以帮忙仅仅五阶的式子,也十分感激!
赋值部分如下:
(from line 45)
w(1)=U(1,6)/M(1,5);
w(1)
U(1,6)=0;
M(1,6)=0;
% M(1,5)=0;
U (2,:) = M (1,:);
Z(1,:)=U(1,:)-M(1,:).*w(1);
% Z(1,6)=0;
U (2,:) = M (1,:);
M (2,:) = Z (1,:);
w(2)= U (2,5)/M (2,5);
w(2)
U(2,5)=0;
M(2,5)=0;
Z(2,:)=U(2,:)-M(2,:).*w(1);
整体code如下, 当然如果只帮忙看看5阶的代码也感谢! :)
function g = fostertocauerdiode5b(N,D)
%clc
x=size(N);y=size(D);
L=size(N)-size(D);
if (L(1,2)>0)
D((y(1,2)+1):x(1,2))=0;
end
if (L(1,2)<0)
N((x(1,2)+1):y(1,2))=0;
end
clear x y L;
syms s;
L=size(D);
P=L(1,2);
j=1;q=1;
for i=1:P
if N(i)~=0
A(j)=N(i)*s^(i-1);
j=j+1;
end
if D(i)~=0
B(q)=D(i)*s^(i-1);
q=q+1;
end
end
M(1,:)=A(1,:);
% The matrix built by numerator after the first calculation...............
U(1,:)=B(1,:);
%The matrix built by numerator after the first calculation...............
w(1)=U(1,6)/M(1,5);
W(1)=w(1,1); %.....................
W(1)
x=size(M);y=size(U);
L=size(M)-size(U);
if (L(1,2)>0)
U((y(1,2)+1):x(1,2))=0;
end
if (L(1,2)<0)
M((x(1,2)+1):y(1,2))=0;
end
clear x y L;
Z(1,:)=U(1,:)-M(1,:)*w(1);%
%z(1)=sum(U(1,:)')'-sum(M(1,:)')'*W(1);
k=2;
while (P-1)~=0
% while sum(Z(k-1,:)')~=0 % sum(A) treats the columns of it as vectors, returning a row vector of the sums of each column.Then it shows the sum of each row
% L=size(Z);
U(k,:)=M(k-1,:);
%clear M;
M(k,:)=Z((k-1),:);
% clear L;
w(k)=U(k,(P-1))/M(k,(j-1));
W(k)=w(k);
% x=size(M);y=size(U);
% L=size(M)-size(U);
% if (L(1,2)>0)
% U(:,(y(1,2)+1):x(1,2))=0;
% end
% if (L(1,2)<0)
% M(:,(x(1,2)+1):y(1,2))=0;
% end
% clear x y;
% % clear x y L;
Z(k,:)=Z((k-1),:)-U(k,:)*W(k);
W(k)
if P == j
j=j-1;
end
if P ~= j
P=P-1;
end
k=k+1;
end
end
谢谢! |