Functions > Vector and Matrix > Matrix Factorization > Example: SVD Matrix Factorization
Example: SVD Matrix Factorization
Use the svd function to perform SVD factorization of matrices. This is useful in solving linear systems. The algorithms underlying these functions are also used in lsolve.
1. Input a real matrix M (not necessarily square).
2. Use the svd function to perform SVD decomposition of matrix M. Uncollapse the nested matrices to view their content.
3. Show that the svds function returns a vector of singular values of matrix M, and that it is identical to the first nested array of the results returned by the svd function.
4. Set variables s, U and V to be element 0, 1 and 2, respectively of matrix S.
5. Use the diag function to create a matrix whose diagonal elements are the elements of s.
6. Show that the product of U, D and V returns input matrix M.
The two matrices are identical.
Was this helpful?