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
 4  0  0  
 0  1  5  
 5  0  2  
--> b = inv(a)
b = 
  <float>  - size: [3 3]
 
Columns 1 to 3
  0.250   0.000   0.000  
  3.125   1.000  -2.500  
 -0.625  -0.000   0.500  
--> a*b
ans = 
  <float>  - size: [3 3]
 
Columns 1 to 3
 1  0  0  
 0  1  0  
 0  0  1  
--> b*a
ans = 
  <float>  - size: [3 3]
 
Columns 1 to 3
 1  0  0  
 0  1  0  
 0  0  1