MATLAB Function Reference
full

Convert sparse matrix to full matrix

Syntax

• ```A = full(S)
```

Description

```A = full(S) ``` converts a sparse matrix `S` to full storage organization. If `S` is a full matrix, it is left unchanged. If `A` is full, `issparse(A)` is `0`.

Remarks

Let `X` be an `m`-by-`n` matrix with `nz` `=` `nnz(X)` nonzero entries. Then `full(X)` requires space to store `m*n` real numbers while `sparse(X)` requires space to store `nz` real numbers and `(nz+n)` integers.

On most computers, a real number requires twice as much storage as an integer. On such computers, `sparse(X)` requires less storage than `full(X)` if the density, `nnz/prod(size(X))`, is less than one third. Operations on sparse matrices, however, require more execution time per element than those on full matrices, so density should be considerably less than two-thirds before sparse storage is used.

Examples

Here is an example of a sparse matrix with a density of about two-thirds. `sparse(S)` and `full(S)` require about the same number of bytes of storage.

• ```S = sparse(+(rand(200,200) < 2/3));
A = full(S);
whos
Name     Size      Bytes   Class
A    200X200   320000   double array
S    200X200   318432   double array (sparse)
```

`sparse`