0
0
MATLABdata~20 mins

Eigenvalues and eigenvectors (eig) in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Eigen Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of eigenvalues and eigenvectors for a 2x2 matrix
What is the output of the following MATLAB code?
A = [2 1; 1 2]; [V,D] = eig(A); disp(D); disp(V);
MATLAB
A = [2 1; 1 2];
[V,D] = eig(A);
disp(D);
disp(V);
A
[1 0; 0 3]
[[-0.7071 0.7071]; [0.7071 0.7071]]
B
[3 0; 0 1]
[[0.7071 -0.7071]; [0.7071 0.7071]]
C
[2 1; 1 2]
[[1 0]; [0 1]]
D
[0 0; 0 0]
[[0 0]; [0 0]]
Attempts:
2 left
💡 Hint
Remember that eig returns eigenvalues in ascending order on the diagonal of D and corresponding eigenvectors in V.
🧠 Conceptual
intermediate
1:30remaining
Understanding eigenvalue multiplicity
Consider the matrix A = [2 0; 0 2]. How many distinct eigenvalues does A have?
ATwo distinct eigenvalues
BOne eigenvalue with multiplicity two
CNo eigenvalues
DInfinite eigenvalues
Attempts:
2 left
💡 Hint
Look at the diagonal elements and their values.
🔧 Debug
advanced
1:30remaining
Identify the error in eigenvalue calculation code
What error will the following MATLAB code produce?
A = [1 2; 3 4]; [V,D] = eig(A(1:3,1:3));
MATLAB
A = [1 2; 3 4];
[V,D] = eig(A(1:3,1:3));
AUndefined function or variable 'eig'.
BNo error, outputs eigenvalues and eigenvectors.
CMatrix must be symmetric.
DIndex exceeds matrix dimensions.
Attempts:
2 left
💡 Hint
Check the size of matrix A and the indexing used.
📝 Syntax
advanced
1:30remaining
Syntax error in eigenvalue function usage
Which option contains a syntax error when computing eigenvalues and eigenvectors in MATLAB?
AV, D = eig(A);
B[V,D] = eig A;
C[V,D] = eig(A, 'nobalance');
D[V,D] = eig(A);
Attempts:
2 left
💡 Hint
MATLAB uses square brackets for multiple outputs and does not support comma-separated assignment.
🚀 Application
expert
2:00remaining
Number of eigenvalues for a 3x3 matrix with repeated eigenvalues
Given the matrix B = [5 4 2; 0 1 0; 0 0 1], how many distinct eigenvalues does B have?
AOne eigenvalue with multiplicity three
BNo eigenvalues
CTwo distinct eigenvalues
DThree distinct eigenvalues
Attempts:
2 left
💡 Hint
Look for eigenvalues on the diagonal and consider repeated values.