Code error need help

조회 수: 9 (최근 30일)
joey anderson
joey anderson 2018년 9월 9일
답변: Walter Roberson 2018년 9월 9일
I keep getting this error I don't know what I am doing wrong. Any help!?
Warning: Matrix is singular to working precision.
> In Untitled (line 54)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
> In Untitled (line 54)
My code
clc;
clear;
error = 10e10;
epsilon = 1e-8;%small value
%Known Values
%Find admittance matrix
%Cartesian YBus
Y = [5-10j -2+4j -3+6j
-2+4j 2-4j 0+0j
-3+6j 0+0j 3-6j];
%Polar YBus
T = angle(Y);
Y = abs(Y);
%known voltages and angles
V(1) = 1;
D(1) = 0;
V(2) = 1.1;
%known injeced active and reactive powers
P(3) = -1.5;
Q(3) = 0.8;
P(2) = 1.5;
%initial guess
V(3) = 0;
D(3) = 0;
D(2) = 0;
%Stage 1
iter = 0;
while error > epsilon
iter = iter + 1;
J = [ -V(2)*V(1)*Y(2,1)*sin(D(2)-D(1)-T(2,1))-V(2)*V(3)*Y(2,3)*sin(D(2)-D(3)-T(2,3)) V(2)*V(3)*Y(2,3)*sin(D(2)-D(3)-T(2,3)) V(2)*Y(2,3)*cos(D(2)-D(3)-T(2,3))
V(3)*V(2)*Y(3,2)*cos(D(3)-D(2)-T(3,2)) -V(3)*V(1)*Y(3,1)*sin(D(3)-D(1)-T(3,1))-V(3)*V(2)*Y(3,2)*sin(D(3)-D(2)-T(3,2)) V(1)*Y(3,1)*cos(D(3)-D(1)-T(3,1))+V(2)*Y(3,2)*cos(D(3)-D(2)-T(3,2))+2*V(3)*Y(3,3)*cos(-T(3,3))
-V(3)*V(2)*Y(3,2)*sin(D(3)-D(2)-T(3,2)) V(3)*V(1)*Y(3,1)*cos(D(3)-D(1)-T(3,1))+V(3)*V(2)*Y(3,2)*cos(D(3)-D(2)-T(3,2)) V(1)*Y(3,1)*sin(D(2)-D(1)-T(3,1))+V(2)*Y(3,2)*sin(D(3)-D(2)-T(3,2))+2*V(3)*Y(3,3)*sin(-T(3,3)) ];
F1 = V(3)*V(1)*Y(3,1)*cos(D(3)-D(1)-T(3,1))+V(3)*V(2)*Y(3,2)*cos(D(3)-D(2)-T(3,2))+V(3)^2*Y(3,3)*cos(-T(3,3))-P(3);
F2 = V(3)*V(1)*Y(3,1)*sin(D(3)-D(1)-T(3,1))+V(3)*V(2)*Y(3,2)*sin(D(3)-D(2)-T(3,2))+V(3)^2*Y(3,3)*sin(D(2)-D(3)-T(3,3))-P(2);
F3 = V(2)*V(1)*Y(2,1)*cos(D(2)-D(1)-T(2,1))+V(2)^2*Y(2,2)*cos(-T(2,2))+V(2)*V(3)*Y(2,3)*cos(D(2)-D(3)-T(2,3))-Q(3);
F = [ F1; F2; F3];
X = [V(3); D(3); D(2)];
X = X - J\F;
V(3) = X(1);
D(3) = X(2);
D( 2) = X(3);
error = max(abs(F));
end
D(2)
V(2)
iter
%Stage 2
%injected active and reactive powers at bus 1 (slack bus)
%PNET(1) = V(1)*V(1)*Y(1,1)*cos(D(1)-D(1)-T(1,1))+V(1)*V(2)*Y(1,2)*cos(D(1)-D(2)-T(1,2))
%QNET(1) = V(1)*V(1)*Y(1,1)*sin(D(1)-D(1)-T(1,1))+V(1)*V(2)*Y(1,2)*sin(D(1)-D(2)-T(1,2))
%QNET(2) = V(2)*V(1)*Y(2,1)*sin(D(2)-D(1)-T(2,1))+V(2)*V(2)*Y(2,2)*sin(D(2)-D(2)-T(2,2))
  댓글 수: 1
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 9일
Share Matlab file (.m)

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

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 9일
This is common for that algorithm. You are asking to solve simultaneous equations that cannot be solved numerically, because either the rows are not independent of each other or else because they are so close to being dependent on each other that any answer would be numeric nonsense because of limited precision of calculation.
You need to go back and recheck the equations and recheck the numeric data.
In some cases I have seen for these kinds of problems, the only solution has been to use a different algorithm, or to recognize that particular configurations of line parameters are unstable and avoid them by modifying the data so the branches are no longer numerically the same.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by