Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.

1 次查看(过去 30 天)
I'm trying to write a function that will solve for the exact DC solution of my circuit through Newton's Method. However I get this error "Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN." Was hoping anyone could help me rectify this. My output should be a solution vector and the number of iterations needed to for convergence. Below is my function and main code.
%%My Function
function [x, iter] = bjt(x0,G)
F = zeros(5,1) ;
J = zeros(5,5) ;
VT = 25.3*exp(-3);
BF = 100;
BR = 1;
Is = 1*exp(-16);
i = 1;
x = x0;
while (norm(F,inf)>(1*exp(-9)))|(i==1)
F = G*x;
F(5) = F(5)-12 ;
J = G;
ID1 = (Is/BR)*((exp(x(1)-x(2))/VT)-1);
F(1) = F(1)+ID1;
F(2) = F(2)-ID1;
J(1,1) = J(1,1) + (Is/(BR*VT))*(exp(x(1)-x(2))/VT);
J(1,2) = J(1,2) - (Is/(BR*VT))*(exp(x(1)-x(2))/VT);
J(2,1) = J(2,1) - (Is/(BR*VT))*(exp(x(1)-x(2))/VT);
J(2,2) = J(2,2) + (Is/(BR*VT))*(exp(x(1)-x(2))/VT);
ID2 = (Is/BF)*((exp(x(1)-x(3))/VT)-1);
F(1) = F(1)+ID2;
F(3) = F(3)-ID2;
J(1,1) = J(1,1) + (Is/(BF*VT))*(exp(x(1)-x(3))/VT);
J(1,3) = J(1,3) - (Is/(BF*VT))*(exp(x(1)-x(3))/VT);
J(3,1) = J(3,1) - (Is/(BF*VT))*(exp(x(1)-x(3))/VT);
J(3,3) = J(3,2) + (Is/(BF*VT))*(exp(x(1)-x(3))/VT);
I0 = Is*(exp((x(1)-x(3))/VT) - exp((x(1)-x(2))/VT));
F(2) = F(2) + I0;
F(3) = F(3) - I0;
y = (-J)\F;
x = x+y;
i = i+1;
end
iter = i-1;
%%MAIN CODE
Vcc = 12;
r1 = 8000;
r2 = 4000;
re = 3300;
rc = 6000;
G = [((1/r1)+(1/r2)), (1/r2), 0, (-1/r1), 0;...
0, (1/rc), 0, (-1/rc), 0;...
0, 0, (1/re), 0, 0;...
0, (-1/rc), 0, (1/rc), 1;...
0, 0, 0, 1, 0];
x0 = [4; 6; 3.3; 12; -0.002]; %%initial guess
[x, iter] = bjt(x0,G);
end

采纳的回答

Walter Roberson
Walter Roberson 2017-3-6
The 3 x 3 J you are producing has rows that are not linearly independent.
You have a number of terms of the form
(Is/(BR*VT))*(exp(x(1)-x(2))/VT)
If your x(1) or x(2) grew to be large and positive then the exp(x(1)-x(2)) could grow to infinity, which would lead to evaluation problems. If they grew to be large and negative then exp(x(1)-x(2)) could shrink to 0, probably leading to duplicate rows or columns.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by