How To Find Eigenvectors In Matlab

How To Articles

In this article, I will guide you through the process of finding eigenvectors in MATLAB. As a long-time MATLAB user, I have found eigenvectors to be an essential tool in my work. Understanding how to find eigenvectors can greatly enhance your ability to analyze and manipulate data.

Before we dive into the code, let’s briefly discuss what eigenvectors are. In linear algebra, eigenvectors represent the directions along which a linear transformation acts by simply scaling the vector. They are crucial in various fields, including physics, engineering, and data analysis.

Step 1: Understanding the Math Behind Eigenvectors

To find eigenvectors, we need to solve the eigenvalue problem for a given matrix. Consider a square matrix A and a vector v. If Av is a scalar multiple of v, then v is an eigenvector of A, and the corresponding scalar factor is called an eigenvalue.

Step 2: Using the eig() Function in MATLAB

Luckily, MATLAB provides us with a built-in function called eig() that can efficiently compute the eigenvectors and eigenvalues of a given matrix. Let’s see how it works:

[V, D] = eig(A);

The eig() function returns two outputs: V and D. V is a matrix whose columns are the eigenvectors of A, and D is a diagonal matrix whose elements are the corresponding eigenvalues. By convention, V’s columns are arranged in the same order as D’s diagonal elements.

Step 3: Applying the eig() Function in MATLAB

Now that we understand the theory and know how to use the eig() function, let’s apply it to a practical example. Suppose we have the following matrix:

A = [2 1; 1 3];

To find the eigenvectors and eigenvalues, we can simply call:

[V, D] = eig(A);

In MATLAB, the resulting eigenvectors are stored as columns in the matrix V, while the eigenvalues are stored on the diagonal of the matrix D. You can access them individually or use them as needed in your code.


Let’s print the eigenvectors and eigenvalues for the matrix A:



The output will be:

0.8507 -0.5257
0.5257 0.8507

1.1716 0
0 3.8284

These are the eigenvectors and eigenvalues for the given matrix A.


In this article, we explored the process of finding eigenvectors in MATLAB. By utilizing the eig() function, we were able to easily obtain both the eigenvectors and eigenvalues of a given matrix. Eigenvectors play a vital role in many mathematical and scientific applications, and learning how to find them can greatly enhance your analytical capabilities. Remember, MATLAB provides powerful tools like eig() to simplify complex computations and save time in your data analysis tasks.