0
0
MATLABdata~5 mins

Eigenvalues and eigenvectors (eig) in MATLAB

Choose your learning style9 modes available
Introduction

Eigenvalues and eigenvectors help us understand important properties of a matrix, like how it stretches or rotates space.

To find the main directions in data for dimensionality reduction.
To analyze stability in systems like engineering or physics.
To solve systems of linear differential equations.
To understand vibrations or modes in mechanical structures.
Syntax
MATLAB
[V,D] = eig(A)

A is a square matrix.

V is a matrix whose columns are eigenvectors of A.

D is a diagonal matrix with eigenvalues of A on the diagonal.

Examples
Find eigenvalues and eigenvectors of a 2x2 matrix.
MATLAB
A = [2 1; 1 2];
[V,D] = eig(A);
Eigenvalues are the diagonal elements, eigenvectors are standard basis vectors.
MATLAB
A = [4 0 0; 0 3 0; 0 0 2];
[V,D] = eig(A);
Matrix with complex eigenvalues and eigenvectors.
MATLAB
A = [0 -1; 1 0];
[V,D] = eig(A);
Sample Program

This program calculates and shows eigenvalues and eigenvectors of matrix A.

MATLAB
A = [3 1; 0 2];
[V,D] = eig(A);
disp('Eigenvalues:');
disp(diag(D));
disp('Eigenvectors:');
disp(V);
OutputSuccess
Important Notes

Eigenvalues can be real or complex numbers.

Eigenvectors are usually normalized (length 1) in MATLAB output.

Order of eigenvalues in D matches columns of V.

Summary

Use eig to find eigenvalues and eigenvectors of square matrices.

Eigenvalues tell how the matrix scales vectors; eigenvectors show directions.

Useful in many fields like data analysis, physics, and engineering.