0
0
MATLABdata~10 mins

Eigenvalues and eigenvectors (eig) in MATLAB - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Eigenvalues and eigenvectors (eig)
Input matrix A
Call eig(A)
Compute eigenvalues and eigenvectors
Return eigenvalues (D) and eigenvectors (V)
Use or display results
Start with a matrix A, call eig(A) to find its eigenvalues and eigenvectors, then use or display these results.
Execution Sample
MATLAB
A = [2 1; 1 2];
[V,D] = eig(A);
disp(D);
disp(V);
This code finds eigenvalues and eigenvectors of matrix A and displays them.
Execution Table
StepActionMatrix/VariableResult/Value
1Define matrix AA[2 1; 1 2]
2Call eig(A)eig(A)Compute eigenvalues and eigenvectors
3Calculate eigenvaluesD[1 0; 0 3] (diagonal matrix)
4Calculate eigenvectorsV[ -0.7071 0.7071; 0.7071 0.7071 ]
5Display Ddisp(D)Shows eigenvalues on diagonal
6Display Vdisp(V)Shows eigenvectors as columns
7EndAll eigenvalues and eigenvectors computed
💡 All eigenvalues and eigenvectors computed and displayed
Variable Tracker
VariableStartAfter eig callFinal
A[2 1; 1 2][2 1; 1 2][2 1; 1 2]
Dundefined[1 0; 0 3][1 0; 0 3]
Vundefined[-0.7071 0.7071; 0.7071 0.7071][-0.7071 0.7071; 0.7071 0.7071]
Key Moments - 3 Insights
Why are eigenvalues shown in a diagonal matrix D instead of a simple list?
In the execution_table row 3, eigenvalues are stored in a diagonal matrix D because MATLAB's eig function returns them this way to align with eigenvectors in V.
Why are eigenvectors shown as columns in matrix V?
As shown in row 4, each column of V corresponds to an eigenvector matching the eigenvalue in the same column of D, so columns represent eigenvectors.
What does the eig function actually compute?
From rows 2-4, eig computes values λ and vectors v such that A*v = λ*v, which are the eigenvalues and eigenvectors.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what does matrix D represent?
AMatrix of eigenvectors
BThe original matrix A
CA diagonal matrix of eigenvalues
DA matrix of zeros
💡 Hint
Refer to execution_table row 3 where D is described as a diagonal matrix of eigenvalues
At which step are eigenvectors first computed according to the execution_table?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Check execution_table row 4 where eigenvectors V are calculated
If matrix A was changed to a 3x3 matrix, how would the size of D and V change?
AD would be 3x1 and V would be 3x3
BD and V would both be 3x3 matrices
CD would be 3x3 and V would be 3x1
DD and V would both be 1x3 matrices
💡 Hint
Refer to variable_tracker showing D and V are square matrices matching size of A
Concept Snapshot
eig(A) returns eigenvalues and eigenvectors of matrix A.
Syntax: [V,D] = eig(A)
D is diagonal matrix of eigenvalues.
Columns of V are eigenvectors.
Used to solve A*v = lambda*v.
Full Transcript
We start with a matrix A. When we call eig(A), MATLAB calculates eigenvalues and eigenvectors. The eigenvalues are returned in a diagonal matrix D, where each diagonal element is an eigenvalue. The eigenvectors are returned as columns in matrix V, each corresponding to an eigenvalue in D. We display D and V to see the results. This process helps us understand how matrix A transforms vectors by scaling them along eigenvectors.