Inverse matrix in Matlab

To calculate the inverse of a square matrix in Matlab, use the inv() function.

inv(m),

where m is a matrix array.

How it Works

First, define a square matrix and assign it to a variable, here called M:

M = [1,2;3,4]

In this example, M is a 2x2 matrix:

$$ M= \begin{pmatrix} 1 & 2 \\
3 & 4 \end{pmatrix} $$

Next, compute the inverse matrix using the inv() function and store the result in the variable M2:

M2 = inv(M)

The content in M2 is the inverse of M, with decimal-format elements:

$$ \begin{pmatrix} -2.00000 & 1.00000 \\
1.50000 & -0.50000 \end{pmatrix} $$

This can also be represented as $$ M2 = \begin{pmatrix} -2 & 1 \\
1.5 & -0.5 \end{pmatrix} $$

 
 

Please feel free to point out any errors or typos, or share suggestions to improve these notes. English isn't my first language, so if you notice any mistakes, let me know, and I'll be sure to fix them.

FacebookTwitterLinkedinLinkedin
knowledge base

Matrix in Matlab