0
0
MATLABdata~10 mins

Singular value decomposition (svd) in MATLAB - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Singular value decomposition (svd)
Start with matrix A
Compute U, S, V such that A = U*S*V'
U: orthogonal matrix (left singular vectors)
S: diagonal matrix (singular values)
V: orthogonal matrix (right singular vectors)
Use U, S, V for analysis or reconstruction
End
Start with matrix A, compute matrices U, S, V so that A equals U times S times V transpose, then use these matrices for further tasks.
Execution Sample
MATLAB
A = [3 1 1; -1 3 1];
[U,S,V] = svd(A);
U
S
V
This code computes the singular value decomposition of matrix A and shows the matrices U, S, and V.
Execution Table
StepActionEvaluationResult
1Define matrix AA = [3 1 1; -1 3 1]A = [3 1 1; -1 3 1]
2Call svd(A)Compute U, S, V such that A = U*S*V'U, S, V matrices computed
3Display UShow left singular vectorsU = [0.71 0.71; 0.71 -0.71] (approx)
4Display SShow singular values on diagonalS = diag([3.87, 2.24]) (approx)
5Display VShow right singular vectorsV = [0.82 0.41 0.41; -0.45 0.89 0; 0.37 0.18 -0.91] (approx)
6Verify reconstructionCalculate U*S*V'Reconstructed A matches original A
7EndNo more stepsExecution complete
💡 All matrices computed and verified, svd process complete
Variable Tracker
VariableStartAfter svdFinal
A[3 1 1; -1 3 1][3 1 1; -1 3 1][3 1 1; -1 3 1]
Uundefined[0.71 0.71; 0.71 -0.71][0.71 0.71; 0.71 -0.71]
Sundefined[3.87 0 0; 0 2.24 0][3.87 0 0; 0 2.24 0]
Vundefined[0.82 0.41 0.41; -0.45 0.89 0; 0.37 0.18 -0.91][0.82 0.41 0.41; -0.45 0.89 0; 0.37 0.18 -0.91]
Key Moments - 3 Insights
Why is matrix S diagonal and not full?
Matrix S contains singular values only on its diagonal, representing the strength of each component. This is shown in execution_table step 4 where S is diagonal with singular values.
Why do we multiply U, S, and V' to get back A?
Because svd decomposes A into U, S, and V such that A = U*S*V'. This is verified in execution_table step 6 where reconstruction matches original A.
Are U and V always square and orthogonal?
Yes, U and V are orthogonal matrices with orthonormal columns, as shown in execution_table steps 3 and 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what does matrix S represent?
AMatrix of left singular vectors
BMatrix of right singular vectors
CDiagonal matrix of singular values
DOriginal matrix A
💡 Hint
Refer to execution_table row 4 where S is described as singular values on diagonal
At which step in the execution_table do we verify that U*S*V' reconstructs A?
AStep 3
BStep 6
CStep 5
DStep 2
💡 Hint
Check execution_table row 6 where reconstruction is verified
If matrix A was square and symmetric, what would you expect about U and V?
AU and V would be identical
BU would be zero matrix
CV would be diagonal
DS would be zero matrix
💡 Hint
Recall that for symmetric matrices, U and V are equal (related to eigen decomposition)
Concept Snapshot
Singular value decomposition (svd) splits matrix A into U, S, V such that A = U*S*V'.
U and V are orthogonal matrices with singular vectors.
S is diagonal with singular values.
Use svd to analyze or reconstruct A.
In MATLAB: [U,S,V] = svd(A);
Full Transcript
Singular value decomposition (svd) breaks a matrix A into three matrices: U, S, and V. U and V are orthogonal matrices containing singular vectors, and S is a diagonal matrix with singular values. The product U*S*V' reconstructs the original matrix A. In MATLAB, you use [U,S,V] = svd(A) to compute these matrices. This process helps analyze the structure of A and is useful in many applications like data compression and noise reduction.