Eigenvalue Decomposition in MATLAB

Mehak Mubarik Apr 12, 2022
  1. Eigenvalue Decomposition of a Matrix Into Its Eigenvalues and Eigenvectors in MATLAB
  2. Use the eig() Function to Decompose Any Matrix Into Its Eigenvalues and Eigenvectors in MATLAB
Eigenvalue Decomposition in MATLAB

We will look at different ways to decompose any matrix into its eigenvalues and eigenvectors in MATLAB.

Eigenvalue Decomposition of a Matrix Into Its Eigenvalues and Eigenvectors in MATLAB

We will use different example codes and related outputs to clear your concepts and give you a complete insight into methods to decompose any matrix into its eigenvalues and eigenvectors in MATLAB. Note that an eigenfunction decomposes a matrix into its constituents.

It also decorrelates our matrix or data. We also use it to reduce the dimensions of our matrix to reduce the complexity.

We also call this decomposition matrix-diagonalization.

The decomposition of any matrix into its eigenvalues and eigenvectors can be Cholesky decomposition or Hessenberg decomposition, etc., depending on our choice of requirements. Let us understand these concepts by looking at the following examples.

Use the eig() Function to Decompose Any Matrix Into Its Eigenvalues and Eigenvectors in MATLAB

Let’s assume a square matrix M.

$$ M\ =\ \begin{matrix} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9\\ \end{matrix} $$

A square matrix M has an eigenvalue (a scalar lambda λ) and an eigenvector as a non-zero vector A when they satisfy the equation MA = λA. We get a matrix that satisfies MV = VΛ with a diagonal matrix with eigenvalues and equivalent eigenvectors on matrix V’s columns.

Note that if our matrix V is a non-singular matrix, we define our eigendecomposition as M = VΛV-1.

Let’s understand this concept with the following example.

Code:

M=[1 2 3;4 5 6;7 8 9]
lambda = eig(M)
[V,D] = eig(M)

Output:

eigen decomposition

We used the eig(M) function on our vector-matrix M in this example. The function eig(M) returned a diagonal matrix.

We represent this matrix as D. The function eig(M) also returned a matrix containing corresponding eigenvectors (the right eigenvectors of our matrix M).

The matrix M, the output vector v and the diagonal matrix D must satisfy the equation M*V = V*D. If our matrix M is a real symmetric, a skew-Hermitain or a Herimitain, then the eigenvectors of our matrix M will be orthonormal.

Let’s again understand this concept through another example.

Code:

A = gallery('circul',3)
[V,D] = eig(A) %calculating eigenvalues-and-eigenvectors of our matrix
A*V - V*D %in order to varify our results

Output:

eigen decomposition 2nd example

Note that eigendecomposition ideally satisfies the equation M*V = V*D. But, in actuality, the function eig() conducts the eigen-decomposition using floating-point-calculations, so AV can only approximate VD.

In other words, AV - VD approaches but does not equal 0.

Mehak Mubarik avatar Mehak Mubarik avatar

Mehak is an electrical engineer, a technical content writer, a team collaborator and a digital marketing enthusiast. She loves sketching and playing table tennis. Nature is what attracts her the most.

LinkedIn