Not quite sure what this means. "Warning: Matrix is singular to working precision."
I have a 3x4 matrix called matrix bestM matrix Q is 3x3 of bestM and matrix m is the last column of bestM
I would like to do C = -Inverse matrix of Q * matrix m and I get that warning and C =[Inf Inf Inf] which isn't right because i am calculating for the camera center in the world
bestM = [-0.0031 -0.0002 0.0005 0.9788;
-0.0003 -0.0006 0.0028 0.2047;
-0.0000 -0.0000 0.0000 0.0013];
Q = bestM(1:3,1:3);
m = bestM(:,4);
X = inv(Q);
C = -X*m;
disp(C);
As found here, a singular matrix is one that does not have an inverse. As dvreed77 already pointed out, you can think of this as 1/0 for matrices.
Why I'm answering, is to tell you that using
inv
explicitly is almost never a good idea. If you need the same inverse a few hundred times, it might be worth it, however, in most circumstances you're interested in the productC
:which can be computed much more accurately and faster in Matlab using the backslash operator:
Type
help slash
for more information on that. And even if you happen to find yourself in a situation where you really need the inverse explicitly, I'd still advise you to avoidinv
:Below is a little performance test to demonstrate one of the very few situations where the explicit inverse can be handy:
Results:
It should be clear that an explicit inverse has its uses, but just as a
goto
construct in any language -- use it sparingly and wisely.A singular matrix can be thought of as the matrix equivalent of zero, when you try to invert 0 it blows up (goes to infinity) which is what you are getting here. user 1281385 is absolutely wrong about using the format command to increase precision; the format command is used to change the format of what is shown to you. In fact the very first line of the help command for format says