Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

full

Convert sparse matrix to full matrix

Syntax

A = full(S)

Description

A = full(S) converts a sparse matrix S to full storage organization, such that issparse(A) returns logical 0 (false). If S is a full matrix, then A is identical to S.

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(double(rand(200,200) < 2/3));
A = full(S);
whos

Name        Size              Bytes  Class     Attributes

  A         200x200            320000  double              
  S         200x200            429624  double    sparse    

More About

collapse all

Tips

If X is an m-by-n matrix with nz nonzero elements then full(X) requires space to store m*n elements. On the other hand, sparse(X) requires space to store nz elements and (nz+n+1) integers.

The density of a matrix (nnz(X)/numel(X)) determines whether or not it is more efficient to store the matrix as sparse or full. The exact crossover point depends on the matrix class as well as the platform. For example, in 32-bit MATLAB®, a double sparse matrix with less than about 2/3 density will require less space than the same matrix in full storage. In 64-bit MATLAB, however, double matrices with less than half of their elements nonzero are more efficient to store as sparse matrices.

See Also

|

Introduced before R2006a

Was this topic helpful?