MATLAB Function Reference |

**Syntax**

**Description**

```
svds(A)
```

computes the five largest singular values and associated singular vectors of the matrix `A`

.

```
svds(A,k)
```

computes the `k`

largest singular values and associated singular vectors of the matrix `A`

.

```
svds(A,k,0)
```

computes the `k`

smallest singular values and associated singular vectors.

With one output argument, `s`

is a vector of singular values. With three output arguments and if `A`

is `m`

-by-`n`

:

`U`

is`m`

-by-`k`

with orthonormal columns`S`

is`k`

-by-`k`

diagonal`V`

is`n`

-by-`k`

with orthonormal columns`U*S*V'`

is the closest rank`k`

approximation to`A`

**Algorithm**

svds(A,k) uses `eigs`

to find the `k`

largest magnitude eigenvalues and corresponding eigenvectors of `B = [0 A; A' 0]`

.

svds(A,k,0) uses `eigs`

to find the `2k`

smallest magnitude eigenvalues and corresponding eigenvectors of `B = [0 A; A' 0]`

, and then selects the `k`

positive eigenvalues and their eigenvectors.

**Example**

`west0479`

is a real 479-by-479 sparse matrix. `svd`

calculates all 479 singular values. `svds`

picks out the largest and smallest singular values.

These plots show some of the singular values of `west0479`

as computed by `svd `

and `svds`

.

The largest singular value of `west0479`

can be computed a few different ways:

svds(west0479,1) = 3.189517598808622e+05 max(svd(full(west0479))) = 3.18951759880862e+05 norm(full(west0479)) = 3.189517598808623e+05

**See Also**

svd | switch |