How to inverse a matrix efficiently?

56 views (last 30 days)
Hi All,
I have a 6x6 matrix with many symbolic variables inside.
I am looking to invert this matrix.
The matrix i have is the "stiffness matrix" in solid mechanics, and i'm looking to get the "compliance matrix" which is just the inverse.
I am not solving a linear set of equations, so the A\b trick doesnt work for me.
Is there a way to mimic the steps of the A\b inverse on a single matrix? I suspect no otherwise the command would already exist, but i may as well ask.
Any help would be greatly appreciated
Thanks!

Accepted Answer

Mohammad Abouali
Mohammad Abouali on 28 Sep 2014
Edited: Mohammad Abouali on 28 Sep 2014
if you are not looking for symbolic solution to the matrix inversion, but you have the numerical values of the entries in the 6x6 matrix and you want to know the numerical values for the inverse of that try this:
Ainv= A\eye(6);
or
Ainv=inv(A);
This would give you the inverse of A numerically.
Try this code, it would give you the inverse of a 6x6 mtrix symbolically. (hence you need symbolic toolbox of MATLAB) (and don't try this on big matrices):
for i=1:6
for j=1:6
eval(['syms a' num2str(i) num2str(j) ' real']);
eval(['A(' num2str(i) ',' num2str(j) ')= a' num2str(i) num2str(j) ';']);
end
end
Ainv=inv(A)
The inverse would be an ugly looking matrix with lots of terms in it. Try to use simplify or something on terms to make it easier to read. Or sometimes I paste it in a text editor and manually simplify it myself. for example I go and using find and replace that exists in every editor I say for example replace every a11*a22-a12*a21 by T1 and so on.

More Answers (1)

Image Analyst
Image Analyst on 28 Sep 2014
Edited: Image Analyst on 28 Sep 2014
Have you tried the inv() function to compute the inverse of a matrix?

Tags

Community Treasure Hunt

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

Start Hunting!