The eig function computes the eigenvalues and eigenvectors of a square matrix. Eigenvalues are scalars that show how a matrix stretches or shrinks vectors, and eigenvectors are the directions that remain unchanged except for scaling.
Click to reveal answer
beginner
How do you call eig to get both eigenvalues and eigenvectors of a matrix A?
Use the syntax [V, D] = eig(A); where V contains eigenvectors as columns and D is a diagonal matrix with eigenvalues on the diagonal.
Click to reveal answer
beginner
What is the size of the output matrix D when you use [V, D] = eig(A); for an n x n matrix A?
The matrix D is an n x n diagonal matrix where each diagonal element is an eigenvalue of A. Off-diagonal elements are zero.
Click to reveal answer
beginner
If v is an eigenvector of matrix A with eigenvalue λ, what equation does it satisfy?
It satisfies the equation A * v = λ * v. This means multiplying A by v just stretches or shrinks v by λ.
Click to reveal answer
intermediate
Can eig return complex eigenvalues and eigenvectors? When does this happen?
Yes, eig can return complex eigenvalues and eigenvectors if the matrix A is not symmetric or has complex entries. This means the matrix can rotate vectors as well as stretch them.
Click to reveal answer
What does the diagonal matrix D returned by [V, D] = eig(A); contain?
AEigenvalues of matrix A
BEigenvectors of matrix A
CInverse of matrix A
DTranspose of matrix A
✗ Incorrect
The diagonal matrix D contains the eigenvalues of A on its diagonal.
If v is an eigenvector of A with eigenvalue λ, what is A * v equal to?
A<code>v</code>
B<code>λ * v</code>
C<code>A</code>
D<code>λ</code>
✗ Incorrect
By definition, A * v = λ * v.
Which MATLAB command returns only the eigenvalues of a matrix A?
A<code>eigen(A)</code>
B<code>eig(A, 'vector')</code>
C<code>eig(A, 'matrix')</code>
D<code>eig(A)</code>
✗ Incorrect
The command eig(A) returns a vector of eigenvalues.
What is the size of the eigenvector matrix V returned by [V, D] = eig(A); for an n x n matrix?
A<code>n x 1</code>
B<code>1 x n</code>
C<code>n x n</code>
D<code>2n x n</code>
✗ Incorrect
The matrix V is n x n with each column an eigenvector.
When might eig return complex eigenvalues?
AFor non-symmetric or complex matrices
BOnly for diagonal matrices
COnly for symmetric matrices
DNever returns complex eigenvalues
✗ Incorrect
Non-symmetric or complex matrices can have complex eigenvalues.
Explain in your own words what eigenvalues and eigenvectors represent for a matrix.
Think about how a matrix changes a vector's length and direction.
You got /3 concepts.
Describe how to use MATLAB's eig function to find eigenvalues and eigenvectors of a matrix.
Remember the order of outputs and what each represents.
You got /3 concepts.
Practice
(1/5)
1. What does the MATLAB function eig return when applied to a square matrix?
easy
A. Eigenvalues and eigenvectors of the matrix
B. Only the eigenvalues of the matrix
C. Only the eigenvectors of the matrix
D. The inverse of the matrix
Solution
Step 1: Understand the purpose of eig
The eig function in MATLAB is designed to compute eigenvalues and eigenvectors of a square matrix.
Step 2: Recall the output of eig
When called with two output arguments, [V,D] = eig(A), it returns eigenvectors in V and eigenvalues in diagonal matrix D.
Final Answer:
Eigenvalues and eigenvectors of the matrix -> Option A
Quick Check:
eig returns eigenvalues and eigenvectors [OK]
Hint: Remember: eig returns both eigenvalues and eigenvectors [OK]
Common Mistakes:
Thinking eig returns only eigenvalues
Confusing eig with inverse function
Assuming eig returns a scalar
2. Which of the following is the correct syntax to get eigenvalues and eigenvectors of matrix A in MATLAB?
easy
A. [V,D] = eig(A);
B. eig = [V,D](A);
C. V, D = eig(A);
D. eig(A) -> [V,D];
Solution
Step 1: Recall MATLAB function call syntax
In MATLAB, functions return outputs using square brackets for multiple outputs, e.g., [out1, out2] = function(input);.
Step 2: Match correct syntax for eig
The correct way to get eigenvectors V and eigenvalues D is [V,D] = eig(A);.
Final Answer:
[V,D] = eig(A); -> Option A
Quick Check:
Use square brackets for multiple outputs [OK]
Hint: Use square brackets for multiple outputs in MATLAB [OK]
Common Mistakes:
Using commas instead of brackets for outputs
Assigning outputs incorrectly
Using arrow notation which is invalid in MATLAB
3. Given the matrix A = [2 0; 0 3];, what is the output of [V,D] = eig(A); D?
medium
A. [[5 0]; [0 0]]
B. [[3 0]; [0 2]]
C. [[2 0]; [0 3]]
D. [[0 2]; [3 0]]
Solution
Step 1: Identify eigenvalues of matrix A
Matrix A is diagonal with entries 2 and 3, so eigenvalues are 2 and 3.
Step 2: Understand output of D from eig
D is a diagonal matrix with eigenvalues on the diagonal, so D = [2 0; 0 3].
Final Answer:
[[2 0]; [0 3]] -> Option C
Quick Check:
Diagonal matrix D has eigenvalues 2 and 3 [OK]
Hint: Eigenvalues of diagonal matrix are diagonal entries [OK]
Common Mistakes:
Mixing order of eigenvalues
Confusing eigenvalues with eigenvectors
Expecting eigenvalues as a vector instead of diagonal matrix
4. What is wrong with this MATLAB code snippet to get eigenvalues of matrix A?
eigenvalues = eig(A, 'vector');
medium
A. The matrix A must be square and symmetric
B. The variable name eigenvalues is invalid
C. The function eig requires three output arguments
D. The eig function does not accept 'vector' as a second argument
Solution
Step 1: Check eig function arguments
The MATLAB eig function does not take a second argument like 'vector'. It only takes the matrix as input.
Step 2: Identify correct usage to get eigenvalues as vector
To get eigenvalues as a vector, simply call eig(A) without extra arguments.
Final Answer:
The eig function does not accept 'vector' as a second argument -> Option D
Quick Check:
Check function syntax carefully [OK]
Hint: Check MATLAB function syntax in docs before adding arguments [OK]
Common Mistakes:
Adding unsupported arguments to eig
Assuming eig returns vector by default without output assignment
Confusing eig with other functions
5. You have a matrix A = [4 1 0; 1 4 1; 0 1 4];. How can you find the eigenvector corresponding to the largest eigenvalue using MATLAB?