Code error need help
Show older comments
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 Comment
KALYAN ACHARJYA
on 9 Sep 2018
Share Matlab file (.m)
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!