warning: Matrix is singular
5 views (last 30 days)
Show older comments
Dimitris Georgis
on 21 May 2015
Commented: Dimitris Georgis
on 21 May 2015
Hi,
When i run the code, i get this warning
Matrix is singular, close to singular or badly scaled. Results may be inaccurate.
RCOND = NaN.
and the rest matrices v,var have inf values.
The matrix where i take this warning is 9x9. I attach part of the code to see better where is my fault.
for i=1:num_exp,
distance_hat=distance.*10.^(0.05*sqrt(sigma)*randn(1,N));
m = 2.3026*log10(distance_hat);
var = exp(4*m)*(exp(8*sigma.^2)-exp(4*sigma.^2));
v = var(1,1)+var(1,2:N);
S = eye(N-1).*diag(v) + ~eye(N-1).*var(1,1)
S12 = inv(S)
sol = loc(x,distance_hat,S12);
weighted = loc(x,distance_hat,S12);
end
what should i change to not take this warning?
3 Comments
Accepted Answer
Jan
on 21 May 2015
I guess that the line, which causes the error, is:
S12 = inv(S)
(Please post the complete error message - most of all it is inefficient to let the readers guess, where the error appears.) Then the message means, that there is no inverse of S. Because we do not know, why you create S in the shown way, there is no chance to suggest an improvement.
More Answers (0)
See Also
Categories
Find more on Linear Algebra 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!