next up previous contents
Next: Operating System Functions Up: Transforms/Decompositions Previous: QR QR Decomposition of   Contents

Subsections

SVD Singular Value Decomposition of a Matrix

Usage

Computes the singular value decomposition (SVD) of a matrix. The svd function has three forms. The first returns only the singular values of the matrix:

  s = svd(A)

The second form returns both the singular values in a diagonal matrix S, as well as the left and right eigenvectors.

  [U,S,V] = svd(A)

The third form returns a more compact decomposition, with the left and right singular vectors corresponding to zero singular values being eliminated. The syntax is

  [U,S,V] = svd(A,0)

Function Internals

Recall that sigma_i is a singular value of an M x N matrix A if there exists two vectors u_i, v_i where u_i is of length M, and v_i is of length u_i and

$\displaystyle A v_i = \sigma_i u_i
$

and generally

$\displaystyle A = \sum_{i=1}^{K} \sigma_i u_i*v_i',
$

where K is the rank of A. In matrix form, the left singular vectors u_i are stored in the matrix U as

$\displaystyle U = [u_1,\ldots,u_m], V = [v_1,\ldots,v_n]
$

The matrix S is then of size M x N with the singular values along the diagonal. The SVD is computed using the LAPACK class of functions GESDD.

Examples

Here is an example of a partial and complete singular value decomposition.

--> A = float(randn(2,3))
A = 
  <float>  - size: [2 3]
 
Columns 1 to 3
   -0.036163993        0.69338953         0.59975541      
   -0.14041515        -0.23818725         0.70864934      
--> [U,S,V] = svd(A)
U = 
  <float>  - size: [2 2]
 
Columns 1 to 2
   -0.84994745        -0.52686721      
   -0.52686721         0.84994751      
S = 
  <float>  - size: [2 3]
 
Columns 1 to 3
    1.0030123          0.00000000         0.00000000      
    0.00000000         0.64374167         0.00000000      
V = 
  <float>  - size: [3 3]
 
Columns 1 to 3
    0.10440307        -0.15579510         0.98225647      
   -0.46245861        -0.88198572        -0.090736881     
   -0.88047248         0.44477975         0.16413097      
--> U*S*V'
ans = 
  <float>  - size: [2 3]
 
Columns 1 to 3
   -0.036163971        0.69338948         0.59975529      
   -0.14041501        -0.23818727         0.70864922      
--> svd(A)
ans = 
  <float>  - size: [2 1]
 
Columns 1 to 1
    1.0030123       
    0.64374173


next up previous contents
Next: Operating System Functions Up: Transforms/Decompositions Previous: QR QR Decomposition of   Contents
Samit K. Basu 2005-03-16