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
用的輾轉(zhuǎn)相除的辦法,可如附圖算出結(jié)果。
![矩陣里面取數(shù)值相除消掉最高次項后賦值另一個矩陣怎么可以沒有余項]()
并且自己學(xué)習(xí)寫了一段,然后發(fā)現(xiàn)
輸入N和D =
format longg
N = [1709000 5505000 1632000 47000 144.99]
D = [1 36393000 14591000 779000 8043.2 4.506]
>> fostertocauerdiode5(N,D)
結(jié)果從r5那個值開始,后面的項就消不掉了,可是還是要繼續(xù)算,好糾結(jié)。。。
后來發(fā)現(xiàn)從第一次想要減去最高次項的式子里,因為matlab里面除法得到的商再乘以除數(shù),被被除數(shù)減完還有剩余的最高此項Z(1,:)=U(1,:)-M(1,:).*w(1);
但是我嘗試了從第二次項賦值,還是得不到正確的第二次輾轉(zhuǎn)相除的結(jié)果,求問我這個賦值有什么問題?謝謝!
現(xiàn)在只需要先寫五階的式子,如果有大神可以幫忙僅僅五階的式子,也十分感激!
賦值部分如下:
(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
謝謝! |