% Refer to Mathematics Matlab tutorial: % The MathWorks Inc, % Matlab Mathematics, % (c) Copyright 1984-2004. % % function "svd" % Tutorial MATLAB version7 % % Singular value decomposition Syntax is = svd(X) % % [U,S,V] = svd(X) % [U,S,V] = svd(X,0) % % Description % % The svd command computes the matrix singular value decomposition. % s = svd(X) returns a vector of singular values. % [U,S,V] = svd(X) produces a diagonal matrix S of the same dimension as % X, with nonnegative diagonal elements in decreasing order, and unitary % matrices U and V so that X = U*S*V'. [U,S,V] = svd(X,0) produces the % "economy size" decomposition. If X is m-by-n with m > n, then svd % computes only the first n columns of U and S is n-by-n. % % Examples For the matrix % X = % 1 2 % 3 4 % 5 6 % 7 8 % the statement [U,S,V] = svd(X) % produces U = % -0.1525 -0.8226 -0.3945 -0.3800 % -0.3499 -0.4214 0.2428 0.8007 % -0.5474 -0.0201 0.6979 -0.4614 % -0.7448 0.3812 -0.5462 0.0407 % % S = % 14.2691 0 % 0 0.6268 % 0 0 % 0 0 % % V = % -0.6414 0.7672 % -0.7672 -0.6414 % % The economy size decomposition generated by [U,S,V] = svd(X,0) % produces U = % -0.1525 -0.8226 % -0.3499 -0.4214 % -0.5474 -0.0201 % -0.7448 0.3812 % S = % 14.2691 0 % 0 0.6268 % V = % -0.6414 0.7672 % -0.7672 -0.6414 % % Application: % For the matrix: Y =[ 1 3 5 7 ; 2 4 6 8 ] X=transpose(Y) % The statement is: [U,S,V] = svd(X) disp(' ') disp('We have displayed above the result of the use of [U,S,V] = svd(X) ') disp(' ') disp(' ') disp(' The economy size decomposition generated by [U,S,V] = svd(X,0) gives:') disp(' ') disp('Then Press any Key to Continue ...') disp(' ') disp(' ') pause % The economy size decomposition generated by [U,S,V] = svd(X,0) [U,S,V] = svd(X,0) % % Algorithm svd uses LAPACK routines to compute the singular value % decomposition. Matrix RoutineReal DGESVDComplexZGESVDDiagnostics % If the limit of 75 QR step iterations is exhausted while seeking % a singular value, this message appears: Solution will not converge. % References[1] Anderson, E., Z. Bai, C. Bischof, S. Blackford, % J. Demmel, J. Dongarra, J. Du Croz, A. Greenbaum, S. Hammarling, % A. McKenney, and D. Sorensen, LAPACK User's Guide % (http://www.netlib.org/lapack/lug/lapack_lug.html), % Third Edition, SIAM, Philadelphia, 1999. sv