Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
7 views (last 30 days)
Show older comments
Hello everyone. I have a matrix that is:
0.004648380836025 0.002524412954424 -0.002524412954424 -0.000821180565226 0 0.002524412954424
-0.000626542578981 -0.001620906917604 0.001620906917604 0.002885422409162 0 -0.001620906917604
0.001282496896793 0.002524412954424 -0.002524412954424 0.000861761404389 0 0
0.001534666644492 -0.001620906917604 0.001620906917604 0.001804817797426 0 0
0 -0.002524412954424 0 0.001682941969616 0.002103677462020 -0.002524412954424
0 0.001620906917604 0 -0.001080604611736 -0.001350755764670 0.001620906917604
When i use inv command and take the inverse of this matrix Matlab gives this error:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 6.491115e-18.
And calculate as:
1.0e+18 *
0.527794489188861 0.821991214493020 -0.527794489188860 -0.821991214493019 -0.187357017765717 -0.291791266736634
0.546782553495766 0.851563372520838 -0.546782553495766 -0.851563372520838 2.167585396954012 3.375814241065342
0.634748301693909 0.988561908269674 -0.634748301693909 -0.988561908269674 2.136359227326393 3.327182363275903
-0.527794489188861 -0.821991214493020 0.527794489188861 0.821991214493020 0.187357017765717 0.291791266736634
-0.188332118507258 -0.293309896163827 0.188332118507258 0.293309896163826 2.900873704769964 4.517843116057024
-1.055588978377721 -1.643982428986040 1.055588978377721 1.643982428986039 0.374714035531435 0.583582533473268
When i write this matrix in a inverse matrix calculator, it gives solutions as:
99.1851027125306 -154.47164513524 -8.121274793333 4.80129825 0 0
0 -0.00000000000000002 0 -0.00000000000000001 -198.0658509629958424 -308.46928628023403707
16.5308504520 -25.7452741 -304.53443810 193.8958581 -198.0658 -308.46928628023403707
99.1851027125 154.471645 280.40804319741965166 129.260218 0 0
317.39232868 246.01702263966 -461.646908 -475.46055895 237.679 -370.163
198.3702054 307.99528228 -197.76706 -310.0436 0 0
I write the solutions badly, however i think it is understandable.
Why Matlab gives this error and calculates wrong? I didn't find any solutions to this.
Thanks for helps.
0 Comments
Answers (1)
Bruno Luong
on 28 Apr 2022
Edited: Bruno Luong
on 28 Apr 2022
It's a warning (not really error)
It means your matrix is numerically not invertible (or almost not invertible)
5 Comments
Torsten
on 28 Apr 2022
Edited: Torsten
on 28 Apr 2022
... because of Matlab find inverse with the help of determinant.
I can assure you that this is not the case.
From the MATLAB documentation of inv:
inv performs an LU decomposition of the input matrix (or an LDL decomposition if the input matrix is Hermitian). It then uses the results to form a linear system whose solution is the matrix inverse inv(X). For sparse inputs, inv(X) creates a sparse identity matrix and uses backslash, X\speye(size(X)).
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!