What is Singular Value Decomposition (SVD) in MATLAB?
SVD is a method to break down a matrix into three simpler matrices: U, S, and V, where U and V are orthogonal, and S is diagonal with singular values.
Click to reveal answer
beginner
What does the MATLAB command [U,S,V] = svd(A) return?
It returns matrices U, S, and V such that A = U * S * V'. U and V are orthogonal matrices, and S is a diagonal matrix with singular values.
Click to reveal answer
intermediate
Why are singular values in matrix S always non-negative?
Because singular values represent the lengths of the semi-axes of the ellipse formed by the matrix transformation, which cannot be negative.
Click to reveal answer
intermediate
How can SVD help in image compression in MATLAB?
By keeping only the largest singular values and corresponding vectors, you can approximate the image with fewer data, reducing size while keeping important features.
Click to reveal answer
intermediate
What is the shape of matrices U, S, and V when A is m-by-n?
U is m-by-m, S is m-by-n diagonal, and V is n-by-n. This ensures the multiplication U*S*V' reconstructs A.
Click to reveal answer
In MATLAB, what does the matrix S contain after [U,S,V] = svd(A)?
ARandom values
BEigenvalues of A
CInverse of A
DSingular values on the diagonal
✗ Incorrect
Matrix S contains the singular values of A on its diagonal, sorted from largest to smallest.
Which MATLAB command reconstructs the original matrix A from its SVD components?
AU * S * V'
BU + S + V
CS * U * V
DV * S * U'
✗ Incorrect
The original matrix A is reconstructed by multiplying U, S, and the transpose of V: A = U * S * V'.
What property do matrices U and V have in SVD?
AThey are zero matrices
BThey are diagonal matrices
CThey are orthogonal matrices
DThey are identity matrices
✗ Incorrect
U and V are orthogonal matrices, meaning their columns are perpendicular unit vectors.
If A is 4-by-3, what is the size of matrix V in [U,S,V] = svd(A)?
A3-by-4
B3-by-3
C4-by-3
D4-by-4
✗ Incorrect
Matrix V is n-by-n, so for A of size 4-by-3, V is 3-by-3.
Why might you use only the first few singular values in SVD?
ATo approximate the matrix with less data
BTo make the matrix larger
CTo invert the matrix
DTo find eigenvalues
✗ Incorrect
Using only the largest singular values helps approximate the matrix while reducing data size, useful in compression.
Explain how Singular Value Decomposition breaks down a matrix and what each component represents.
Think of U and V as rotations and S as scaling.
You got /4 concepts.
Describe a practical use of SVD in MATLAB, such as image compression, and how it works.
Focus on how fewer singular values can still keep the main picture.
You got /4 concepts.
Practice
(1/5)
1. What does the MATLAB function svd(A) return when applied to a matrix A?
easy
A. The determinant of matrix A.
B. The inverse of matrix A.
C. Three matrices: U, S, and V such that A = U * S * V'.
D. The transpose of matrix A.
Solution
Step 1: Understand the purpose of svd
The svd function decomposes a matrix into three parts: U, S, and V.
Step 2: Recall the decomposition formula
It satisfies the equation A = U * S * V', where U and V are orthogonal matrices and S is diagonal.
Final Answer:
Three matrices: U, S, and V such that A = U * S * V'. -> Option C
Quick Check:
svd(A) = U, S, V [OK]
Hint: Remember svd splits matrix into U, S, V parts [OK]
Common Mistakes:
Confusing svd with inverse or transpose
Expecting a single matrix output
Thinking svd returns determinant
2. Which of the following is the correct MATLAB syntax to compute the singular value decomposition of matrix A and store the results in U, S, and V?
easy
A. [U, S, V] = svd(A);
B. svd(U, S, V) = A;
C. U, S, V = svd(A);
D. svd(A, U, S, V);
Solution
Step 1: Recall MATLAB function output syntax
In MATLAB, multiple outputs are assigned using square brackets on the left side.
Step 2: Match correct svd syntax
The correct syntax is [U, S, V] = svd(A); to get all three matrices.
Final Answer:
[U, S, V] = svd(A); -> Option A
Quick Check:
Use square brackets for multiple outputs [OK]
Hint: Use square brackets for multiple outputs in MATLAB [OK]
Matrix A is symmetric. Its singular values are the absolute values of eigenvalues. Eigenvalues of A are 4 and 2.
Step 2: Understand svd output
The diagonal of S contains singular values in descending order: 4 and 2.
Final Answer:
[4; 2] -> Option D
Quick Check:
Singular values = eigenvalues for symmetric matrix [OK]
Hint: For symmetric matrices, singular values = absolute eigenvalues [OK]
Common Mistakes:
Confusing singular values with matrix entries
Mixing order of singular values
Expecting singular values to be zero
4. Consider the MATLAB code snippet:
A = [1 2; 3 4]; [U, S, V] = svd(A); U = svd(A);
What is the error in this code?
medium
A. Matrix A is not square, so svd cannot be applied.
B. The second call to svd assigns a matrix to U instead of three outputs.
C. The variable V is not assigned in the second svd call.
D. The svd function requires four output variables.
Solution
Step 1: Analyze the first svd call
The first call correctly assigns three outputs: U, S, V.
Step 2: Analyze the second svd call
The second call assigns U = svd(A); which returns only singular values as a vector, not a matrix U.
Final Answer:
The second call to svd assigns a matrix to U instead of three outputs. -> Option B
Quick Check:
svd(A) alone returns singular values vector [OK]
Hint: svd(A) alone returns singular values vector, not matrices [OK]
Common Mistakes:
Expecting svd(A) to return U matrix alone
Thinking svd requires square matrix only
Ignoring number of outputs in function call
5. You want to approximate a matrix A by keeping only the largest singular value and corresponding vectors using MATLAB. Which code snippet correctly performs this low-rank approximation?