INV Invert Matrix

Section: Transforms/Decompositions

Usage

Inverts the argument matrix, provided it is square and invertible. The syntax for its use is
   y = inv(x)

Internally, the inv function uses the matrix divide operators. For sparse matrices, a sparse matrix solver is used.

Example

Here we invert some simple matrices
--> a = randi(zeros(3),5*ones(3))
a = 
  <int32>  - size: [3 3]
 
Columns 1 to 3
 1  1  4  
 1  0  1  
 0  4  1  
--> b = inv(a)
b = 
  <float>  - size: [3 3]
 
Columns 1 to 3
 -0.36363640   1.36363637   0.09090909  
 -0.09090909   0.09090909   0.27272728  
  0.36363637  -0.36363637  -0.09090909  
--> a*b
ans = 
  <float>  - size: [3 3]
 
Columns 1 to 3
  1.000000000000000   0.000000000000000   0.000000000000000  
 -0.000000029802322   1.000000000000000   0.000000000000000  
  0.000000000000000   0.000000000000000   1.000000000000000  
--> b*a
ans = 
  <float>  - size: [3 3]
 
Columns 1 to 3
  1.000000000000000  -0.000000029802322  -0.000000149011612  
  0.000000000000000   1.000000000000000   0.000000000000000  
  0.000000000000000   0.000000000000000   1.000000000000000