Why won't my matrix invert??? I get FAIL every time. QUICK HELP NEEDED

5 visualizaciones (últimos 30 días)
Drew
Drew el 6 de Ag. de 2014
Editada: John D'Errico el 7 de Ag. de 2014
I have a 15x15 matrix and it won't invert. What I have is
% code
mc = 2; % Disk mass
mg = 1; % Bar mass
mb = 1; % Collar mass
L = 2; % Bar length
r = 1; % Disk radius
g = 9.81; % Gravity
Ig = mg*L^2/12; % Bar moment of inertia
Ic = mc*r^2/2; % Disk moment of inertia
A=[ -mb 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
0 -1 0 0 -mg 1 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 1 -mg 0 0 0 0 0 0 0
0 yb/2 xa/2 0 0 yb/2 xa/2 0 -Ig 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 mc 0 1 0 0 0
0 0 0 0 0 0 -1 0 0 0 0 0 1 0 0
0 0 0 0 0 r 0 0 0 0 Ic r 0 0 0
1 0 0 0 0 0 0 0 yb 0 0 0 0 0 1
0 0 0 0 0 0 0 0 xa 0 0 0 0 1 0
-1 0 0 0 1 0 0 0 -yb/2 0 0 0 0 0 0
0 0 0 0 0 0 0 1 xa/2 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 r 0 0 0 0
0 0 0 0 -1 0 0 0 -yb/2 0 0 0 0 0 1
0 0 0 0 0 0 0 -1 xa/2 0 0 0 0 1 0
];
C = inv(A)
and I tried inverting it with C=inv(A) and C = A^-1 and neither worked. Can anyone see why this is happening?
  1 comentario
dpb
dpb el 6 de Ag. de 2014
Editada: dpb el 6 de Ag. de 2014
>> C = inv(A)
Undefined function or variable 'yb'.
>>
Looking farther I see there's no 'xa', either, at least...

Iniciar sesión para comentar.

Respuestas (1)

Yu Jiang
Yu Jiang el 6 de Ag. de 2014
The reason that the matrix is not invertible is because that it is a singular matrix. In fact, the matrix has a rank of 14, meaning there is one column depending on the other columns. I suggest you check the matrix to see why the dependency occurs.
  3 comentarios
John D'Errico
John D'Errico el 6 de Ag. de 2014
Editada: John D'Errico el 7 de Ag. de 2014
NO NO NO. Do NOT use the determinant to determine if a matrix is singular!
Despite what they taught you in school, a determinant is just a poorly conditioned computation. Yes, it might be ok for a 2x2 matrix. But a 15x15 matrix is just bad mojo to compute a determinant on.
Use rank, cond, or svd to determine if a matrix is singular. NEVER rely on det.
I was going to go into more detail, but I have no idea what yb and xa are. I suppose one can go symbolic for those variables though, so...
syms yb xa
(...)
det(A)
ans =
0
rank(A)
ans =
14
We can go a bit deeper yet, and compute the singular values of A, to find that exactly one of those singular values is identically zero.
John D'Errico
John D'Errico el 7 de Ag. de 2014
I should add, very often matrices like this are singular for a good reason. Usually that singularity is a reflection of the fact that your problem is under-constrained. So it might be possible for example, to translate the entire system by some amount, and change nothing about the minimum energy state of that system. Or perhaps it might be possible to rotate the entire system without any change to the potential energy.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by