Matlab

How to Find the Inverse of a 3×3 Matrix in MATLAB?

Finding the inverse of a 3×3 matrix is an essential operation in linear algebra with numerous applications in various fields, including engineering, physics, and computer science. The matrix inverse allows us to solve systems of linear equations, compute transformations, and analyze the properties of matrices.

This article will explain the step-by-step process of finding the inverse of a 3×3 matrix.

Find the Inverse of a 3-by-3 Matrix in MATLAB

There are two ways to find the inverse of a 3×3 matrix in MATLAB:

Note: If the given matrix is a singular matrix such that det(X)=0, then its inverse does not exist and MATLAB returns a matrix having all NaN entries.

1: Using inv() Function

An inv() is a built-in function in MATLAB that calculates the inverse of any non-singular square matrix with size n. This function accepts a non-singular square matrix as an argument and calculates the inverse of the given matrix.

The inv() function follows a simple syntax in MATLAB that is given below:

Y = inv(X)

 
Here:

Y = inv(X) calculates the inverse of the given nonsingular matrix X.

Example 1

This example creates a 3×3 matrix containing all real entries. Then we use the MATLAB inv() function that computes the inverse of the given matrix and displays the results on the screen.

X = [1 2 3;3 4 5;0 7 5];
Y=inv(X)

 

Example 2

The following MATLAB code creates a 3×3 matrix containing complex entries. Then it uses the MATLAB inv() function that computes the inverse of the given matrix and displays the results on the screen.

X = [1 2i 3-9i;3+2i 4 5; 0 7i 5];
Y=inv(X)

 

2: Using Matrix Expression

Matrix expression (X^(-1)) is another way that allows you to compute the inverse of the given nonsingular square matrix X.

This method follows a simple syntax that is given below:

Y = X^(-1)

 
Here:

X^(-1) is a matrix expression used for finding the inverse of the given nonsingular square matrix X.

Example

This example creates a 3×3 square matrix containing complex entries. Then it computes the inverse of the given matrix using matrix expression and displays the results on the screen.

X = [1 2i 3-9i;3+2i 4 5; 0 7i 5];
Y=X^(-1)

 

Conclusion

Calculating the inverse of a 3×3 matrix is a fundamental operation in linear algebra with practical applications in various fields. This article mentioned two methods for finding the inverse of a 3×3 matrix in MATLAB: using the inv() function and the matrix expression X^(-1). Understanding these functions will help users solve linear equations and analyze matrix transformations.

About the author

Komal Batool Batool

I am passionate to research technologies and new ideas and that has brought me here to write for the LinuxHint. My major focus is to write on programming languages and computer science related topics.