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에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by