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 = 
  <double>  - size: [3 3]
 
Columns 1 to 3
 -0.36363636363636365   1.36363636363636376   0.09090909090909094  
 -0.09090909090909091   0.09090909090909091   0.27272727272727271  
  0.36363636363636365  -0.36363636363636365  -0.09090909090909091  
--> a*b
ans = 
  <double>  - size: [3 3]
 
Columns 1 to 3
 1.0000000000000000e+00  8.3266726846886741e-17  0.0000000000000000e+00  
 0.0000000000000000e+00  1.0000000000000000e+00  2.7755575615628914e-17  
 0.0000000000000000e+00  0.0000000000000000e+00  9.9999999999999989e-01  
--> b*a
ans = 
  <double>  - size: [3 3]
 
Columns 1 to 3
 1.0000000000000000e+00  1.1102230246251565e-16  1.1102230246251565e-16  
 0.0000000000000000e+00  9.9999999999999989e-01  -2.7755575615628914e-17  
 0.0000000000000000e+00  0.0000000000000000e+00  1.0000000000000000e+00