Why I got this "Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN " in this code
2 次查看(过去 30 天)
显示 更早的评论
ER = 1.0;
EO = 8.8541e-12;
AA = 1.0;
BB = 1.0;
D = 1.0;
N = 9;
NT = 2*N;
M = sqrt(N);
DX = AA/M;
DY = BB/M;
DL = DX;
% SECOND, CALCULATE THE ELEMENTS OF THE COEFFICIENT
% MATRIX A
K = 0;
for kii=2:4
for K2=1:M
for K3=1:M
K = K + 1;
X(K) = DX*(K2 - 0.5);
Y(K) = DY*(K3 - 0.5);
end
end
end
for kii=2:N
Z(kii) = 0.0;
Z(kii+N) = D;
end
for I=1:NT
for J=1:NT
if(I==J)
A(I,J) = DL*0.8814/(pi*EO);
else
R = sqrt (X(I)-X(J))^2 == (Y(I)-Y(J) )^2 + ( Z (I)-Z (J) ) ^2 ;
A(I,J) = DL^2/(4.*pi*EO*R);
end
end
end
% NOW DETERMINE THE MATRIX OF CONSTANT VECTOR B
for K=1:N
B(K) = 1.0;
B(K+N) = -1.0;
end
% INVERT A AND CALCULATE RHO CONSISTING
% THE UNKNOWN ELEMENTS
% ALSO CALCULATE THE TOTAL CHARGE Q AND CAPACITANCE C
F = inv(A);
RHO = F*B';
SUM = 0.0;
for I=1:N
SUM = SUM + RHO(I);
end
Q = SUM*(DL^2) ;
VO = 2.0;
C = abs(Q)/VO;
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!