user462715
user462715

Reputation: 41

how to get inverse of matrix in matlab

I'm using matlab.

I have matrix like

9 4 
5 7

Its inverse must be k= [ 7 -4 -5 9]

When I use inv matrix at matlab

inv(k);

I get adouble matrix

Like (not true number)

 .37 -.32
-.32 .44

How can I get the inverse from the previous matrix?

 7 -4
-5  9

Upvotes: 0

Views: 3107

Answers (3)

Loren
Loren

Reputation: 1743

The real question is why you need the inverse. Generally it's better to solve a system of equations. In MATLAB, you typically do that using \. INV has much poorer numerical performance than \ or the underlying methods in \ such as QR and LU.

Upvotes: 8

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272772

This is not the inverse; this is the inverse times the determinant. So you need:

det(k) * inv(k)

Upvotes: 7

duffymo
duffymo

Reputation: 309008

I think this is what the inverse ought to be:

http://www.wolframalpha.com/input/?i=inv{{9,+4},+{5,+7}}

Upvotes: 3

Related Questions