How can I invert the following matrix ?

조회 수: 11 (최근 30일)
aldo angulo
aldo angulo 2018년 5월 31일
댓글: sloppydisk 2018년 5월 31일
I want to extract Ybus from the following code to use in another code (also in MATLAB), however, when I try to invert the matrix it does not allow me to do so. It sends me a warning message and the result is not the result of inverting the obtained matrix. This is the code :
% This program obtains th Bus Admittance Matrix for power flow solution
% Copyright (c) 1998 by H. Saadat
clear all; close all; clc;
linedata=[1 2 0.08 0.24 0 1.0
1 3 0.02 0.06 0 1.0
2 3 0.06 0.18 0 1.0];
j=sqrt(-1); i = sqrt(-1);xxx=1647;
nl = linedata(:,1); nr = linedata(:,2); R = linedata(:,3);
X = linedata(:,4); Bc = j*linedata(:,5); a = linedata(:, 6);
nbr=length(linedata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; y= ones(nbr,1)./Z; %branch admittance
for n = 1:nbr
if a(n) <= 0 ;a(n) = 1; else;end
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
% formation of the off diagonal elements
for k=1:nbr
Ybus(nl(k),nr(k))=Ybus(nl(k),nr(k))-y(k)/a(k);
Ybus(nr(k),nl(k))=Ybus(nl(k),nr(k));
end
end
% formation of the diagonal elements
for n=1:nbus
for k=1:nbr
if nl(k)==n
Ybus(n,n) = Ybus(n,n)+y(k)/(a(k)^2) + Bc(k);
elseif nr(k)==n
Ybus(n,n) = Ybus(n,n)+y(k) +Bc(k);
else
end
end
end
disp(Ybus)
Zbus=inv(Ybus);
disp(Zbus)
The result from matlab is the following:
6.2500 -18.7500i -1.2500 + 3.7500i -5.0000 +15.0000i
-1.2500 + 3.7500i 2.9167 - 8.7500i -1.6667 + 5.0000i
-5.0000 +15.0000i -1.6667 + 5.0000i 6.6667 -20.0000i
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
4.745111e-18.
> In INYBUS (line 32)
1.0e+15 *
1.6661 - 0.0000i 1.6661 - 0.0000i 1.6661 - 0.0000i
1.6661 - 0.0000i 1.6661 - 0.0000i 1.6661 - 0.0000i
1.6661 - 0.0000i 1.6661 - 0.0000i 1.6661 + 0.0000i

답변 (2개)

sloppydisk
sloppydisk 2018년 5월 31일
The system of equations does not have a solution, they are linearly dependent. What do you mean by "the result is not the result of inverting the obtained matrix"? The matrix is simply non-invertible.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 5월 31일
Notice the bit about "Results may be inaccurate". Round-off noise has been magnified to extremes because the matrix is singular.
sloppydisk
sloppydisk 2018년 5월 31일
Why do you expect your matrix to be invertible? If it really should be invertible maybe you made some mistake in setting up the matrix. Otherwise you must simply accept the fact that it is rank-deficient and interpret that answer accordingly.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2018년 5월 31일
>> -Ybus(1,:)-Ybus(2,:)-Ybus(3,:)
ans =
0 0 0
That is, the third row is the negative of the sum of the other two rows. That makes the rank of the matrix 2 instead of 3, and so the matrix cannot be inverted.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by