Matrix is close to singular or badly scaled
Show older comments
Hello,
I am receiving the following error when I attempt a simple matrix division within MATLAB. It follows the form of Ax = B. The line of code I have put in to find x is
x = inv(A) * B
It is returning the error:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.938882e-018. > In example at 4
x =
1.0e+019 *
1.1621
-0.6298
7.0903
The values of the A and B matrices are below.
A = [-180 -152 16; -20 -172 -12; -160 20 28]
B = [-13960; -87501; -52408]
I know what the answer for the x matrix should be, but I need the code to make MATLAB do it, and it is miles out. Can anyone help?
1 Comment
Walter Roberson
on 17 Nov 2011
Please consider using the mldivide ('\') operator instead of using inv(); it would be A\B
http://www.mathworks.com/help/techdoc/ref/mldivide.html
Answers (2)
Jan
on 17 Nov 2011
A = [-180 -152 16; -20 -172 -12; -160 20 28]
det(A)
% >> 0
A is singular. Then you cannot create the inverse. What do you expect as answer for x then?!
Richard
on 17 Nov 2011
0 votes
1 Comment
Jan
on 17 Nov 2011
No. This x does not satisfy the equations:
A = [-180 -152 16; -20 -172 -12; -160 20 28];
B = [-13960; -87501; -52408];
x = [50; 40; 70]; % Column vector!
disp(A * x);
% >> [-13960; -8720; -5240]
A*x is definitely not B.
As I said already: A is singular. Because there is no inverse of a singular matrix, you cannot calculate inv(A)*B. In consequence you can neither make it working nor inmprove it.
Please check the values again for typos.
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!