How can I invert the following matrix ?
9 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
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
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!