
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Features
- MATLAB - Environment Setup
- MATLAB - Editors
- MATLAB - Online
- MATLAB - Workspace
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Dates and Time
- MATLAB - Numbers
- MATLAB - Random Numbers
- MATLAB - Strings and Characters
- MATLAB - Text Formatting
- MATLAB - Timetables
- MATLAB - M-Files
- MATLAB - Colon Notation
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB - Normalize Data
- MATLAB - Predefined Variables
- MATLAB - Decision Making
- MATLAB - Decisions
- MATLAB - If End Statement
- MATLAB - If Else Statement
- MATLAB - If…Elseif Else Statement
- MATLAB - Nest If Statememt
- MATLAB - Switch Statement
- MATLAB - Nested Switch
- MATLAB - Loops
- MATLAB - Loops
- MATLAB - For Loop
- MATLAB - While Loop
- MATLAB - Nested Loops
- MATLAB - Break Statement
- MATLAB - Continue Statement
- MATLAB - End Statement
- MATLAB - Arrays
- MATLAB - Arrays
- MATLAB - Vectors
- MATLAB - Transpose Operator
- MATLAB - Array Indexing
- MATLAB - Multi-Dimensional Array
- MATLAB - Compatible Arrays
- MATLAB - Categorical Arrays
- MATLAB - Cell Arrays
- MATLAB - Matrix
- MATLAB - Sparse Matrix
- MATLAB - Tables
- MATLAB - Structures
- MATLAB - Array Multiplication
- MATLAB - Array Division
- MATLAB - Array Functions
- MATLAB - Functions
- MATLAB - Functions
- MATLAB - Function Arguments
- MATLAB - Anonymous Functions
- MATLAB - Nested Functions
- MATLAB - Return Statement
- MATLAB - Void Function
- MATLAB - Local Functions
- MATLAB - Global Variables
- MATLAB - Function Handles
- MATLAB - Filter Function
- MATLAB - Factorial
- MATLAB - Private Functions
- MATLAB - Sub-functions
- MATLAB - Recursive Functions
- MATLAB - Function Precedence Order
- MATLAB - Map Function
- MATLAB - Mean Function
- MATLAB - End Function
- MATLAB - Error Handling
- MATLAB - Error Handling
- MATLAB - Try...Catch statement
- MATLAB - Debugging
- MATLAB - Plotting
- MATLAB - Plotting
- MATLAB - Plot Arrays
- MATLAB - Plot Vectors
- MATLAB - Bar Graph
- MATLAB - Histograms
- MATLAB - Graphics
- MATLAB - 2D Line Plot
- MATLAB - 3D Plots
- MATLAB - Formatting a Plot
- MATLAB - Logarithmic Axes Plots
- MATLAB - Plotting Error Bars
- MATLAB - Plot a 3D Contour
- MATLAB - Polar Plots
- MATLAB - Scatter Plots
- MATLAB - Plot Expression or Function
- MATLAB - Draw Rectangle
- MATLAB - Plot Spectrogram
- MATLAB - Plot Mesh Surface
- MATLAB - Plot Sine Wave
- MATLAB - Interpolation
- MATLAB - Interpolation
- MATLAB - Linear Interpolation
- MATLAB - 2D Array Interpolation
- MATLAB - 3D Array Interpolation
- MATLAB - Polynomials
- MATLAB - Polynomials
- MATLAB - Polynomial Addition
- MATLAB - Polynomial Multiplication
- MATLAB - Polynomial Division
- MATLAB - Derivatives of Polynomials
- MATLAB - Transformation
- MATLAB - Transforms
- MATLAB - Laplace Transform
- MATLAB - Laplacian Filter
- MATLAB - Laplacian of Gaussian Filter
- MATLAB - Inverse Fourier transform
- MATLAB - Fourier Transform
- MATLAB - Fast Fourier Transform
- MATLAB - 2-D Inverse Cosine Transform
- MATLAB - Add Legend to Axes
- MATLAB - Object Oriented
- MATLAB - Object Oriented Programming
- MATLAB - Classes and Object
- MATLAB - Functions Overloading
- MATLAB - Operator Overloading
- MATLAB - User-Defined Classes
- MATLAB - Copy Objects
- MATLAB - Algebra
- MATLAB - Linear Algebra
- MATLAB - Gauss Elimination
- MATLAB - Gauss-Jordan Elimination
- MATLAB - Reduced Row Echelon Form
- MATLAB - Eigenvalues and Eigenvectors
- MATLAB - Integration
- MATLAB - Integration
- MATLAB - Double Integral
- MATLAB - Trapezoidal Rule
- MATLAB - Simpson's Rule
- MATLAB - Miscellenous
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Inverse of Matrix
- MATLAB - GNU Octave
- MATLAB - Simulink
MATLAB - Eigenvalues and Eigenvectors
Eigenvalues and eigenvectors are fundamental concepts in linear algebra, widely used in various fields, including physics, engineering, and data analysis. In MATLAB, these concepts can be explored and computed easily.
What is EigenValues?
An eigenvalue is a scalar, denoted as (lambda), associated with a linear transformation of a vector space. It represents the factor by which the corresponding eigenvector is scaled during the transformation.
What is EigenVectors?
An eigenvector is a non-zero vector that only changes by a scalar factor when a linear transformation is applied to it. In other words, if A is a matrix, v is an eigenvector of A corresponding to the eigenvalue if −
Av=v
Here, A is a square matrix, v is the eigenvector, and is the eigenvalue.
MATLAB Functions
MATLAB provides built-in functions to compute eigenvalues and eigenvectors.
Using eig
This function computes the eigenvalues and eigenvectors of a matrix.
Syntax
e = eig(A) [V,D] = eig(A) [V,D,W] = eig(A) e = eig(A,B) [V,D] = eig(A,B) [V,D,W] = eig(A,B) [___] = eig(A,balanceOption) [___] = eig(A,B,algorithm) [___] = eig(___,outputForm)
Explanation of Syntax
e = eig(A) returns a column vector with the eigenvalues of the square matrix A.
[V,D] = eig(A) returns a diagonal matrix D with the eigenvalues of A and a matrix V whose columns are the corresponding eigenvectors. This means that multiplying A by V is the same as multiplying V by D.
[V,D,W] = eig(A) also returns a full matrix W whose columns are the corresponding left eigenvectors. This means that multiplying the transpose of W by A is the same as multiplying D by the transpose of W.
The eigenvalue problem is about finding solutions to the equation Av = v, where A is a square matrix, v is a column vector, and is a scalar. The values that satisfy this equation are the eigenvalues, and the v values that satisfy it are the right eigenvectors. The left eigenvectors, w, satisfy the equation w'A = w'.
e = eig(A,B) returns a column vector with the generalized eigenvalues of the square matrices A and B.
[V,D] = eig(A,B) returns a diagonal matrix D with the generalized eigenvalues and a full matrix V whose columns are the corresponding right eigenvectors. This means that multiplying A by V is the same as multiplying B, V, and D together.
[V,D,W] = eig(A,B) also returns a full matrix W whose columns are the corresponding left eigenvectors. This means that multiplying the transpose of W by A is the same as multiplying D, the transpose of W, and B.
The generalized eigenvalue problem is about finding solutions to the equation Av = Bv, where A and B are square matrices, v is a column vector, and is a scalar. The values that satisfy this equation are the generalized eigenvalues, and the v values are the corresponding right eigenvectors. The left eigenvectors, w, satisfy the equation w'A = w'B.
[___] = eig(A, balanceOption), where balanceOption is "nobalance", turns off the preliminary balancing step in the algorithm. By default, balanceOption is "balance", which turns balancing on. The eig function can return any of the output arguments mentioned in the previous examples.
[___] = eig(A,B,algorithm), where algorithm is "chol", uses the Cholesky factorization of B to compute the generalized eigenvalues. The default algorithm depends on the properties of A and B, but it is "qz" (QZ algorithm) when A or B are not symmetric.
[___] = eig(___,outputForm) returns the eigenvalues in the format specified by outputForm, using any of the input or output arguments mentioned earlier. Set outputForm to "vector" to get the eigenvalues in a column vector, or "matrix" to get them in a diagonal matrix.
Examples for Matlab Function eig()
Here are some examples to illustrate how to use it −
Example 1: To calculate eigenvalues using e = eig(A)
In MATLAB, you can find the eigenvalues of matrix A using the eig function. Consider the following code −
% Define the matrix A A = [1, 2, 3; 4, 5, 6; 7, 8, 9]; % Compute the eigenvalues e = eig(A)
In the above example −
- The matrix A is defined as a 3x3 matrix with entries as shown.
- The eig(A) function computes the eigenvalues of matrix A.
- The result of eig(A) is stored in the variable e, which is a column vector containing the eigenvalues of A.
When the code is computed the output we get is as follows −
>> % Define the matrix A A = [1, 2, 3; 4, 5, 6; 7, 8, 9]; % Compute the eigenvalues e = eig(A) e = 16.1168 -1.1168 -0.0000
Example 2: To get eigenValues and eigenVectors using [V,D] = eig(A)
In MATLAB, you can find the eigenvalues and eigenvectors of matrix A using the eig function.
Consider following code −
% Define the matrix A A = [2, -1; 4, 3]; % Compute the eigenvalues and eigenvectors [V, D] = eig(A); % Display the eigenvalues disp('Eigenvalues:'); disp(D); % Display the eigenvectors disp('Eigenvectors:'); disp(V);
In above code we have −
- The matrix A is defined as a 2x2 matrix with entries as shown.
- The [V, D] = eig(A) function computes both the eigenvalues (D) and the corresponding eigenvectors (V) of matrix A.
- D is a diagonal matrix containing the eigenvalues of A.
- V is a matrix whose columns are the corresponding eigenvectors.
When the code is executed the output we get is as follows −
>> % Define the matrix A A = [2, -1; 4, 3]; % Compute the eigenvalues and eigenvectors [V, D] = eig(A); % Display the eigenvalues disp('Eigenvalues:'); disp(D); % Display the eigenvectors disp('Eigenvectors:'); disp(V); Eigenvalues: 2.5000 + 1.9365i 0.0000 + 0.0000i 0.0000 + 0.0000i 2.5000 - 1.9365i Eigenvectors: -0.1118 + 0.4330i -0.1118 - 0.4330i 0.8944 + 0.0000i 0.8944 + 0.0000i