full

Converts a sparse matrix to ordinary full storage.

Category: Mathematics > Sparse Matrices

Syntax

A = full(S)

Returns S with every element stored, zeros included.

Description

A sparse matrix stores only its nonzero entries and their positions. full fills in the zeros so that the matrix can be displayed in the usual grid, indexed quickly or passed to functions that need full input. The memory use grows to numel(S) elements, so avoid it for very large matrices.

Input arguments

S
Sparse or full array. A full array is returned unchanged.

Output arguments

A
Full array of the same size and class.

Example

Sparse to full

S = sparse([1 2 3], [1 2 3], [4 5 6])
A = full(S)
issparse(A)
Output
S = 

   (1,1)        4
   (2,2)        5
   (3,3)        6
A = 3×3

     4     0     0
     0     5     0
     0     0     6
ans = logical
   0

See also

sparse issparse nnz spones