full - Convert sparse matrix to full storage - MATLAB (original) (raw)

Convert sparse matrix to full storage

Syntax

Description

`A` = full([S](#mw%5Fcc01e120-fea8-419b-a679-69edd17e288d)) converts sparse matrix S to full storage organization, such thatissparse(A) returns logical 0 (false).

example

Examples

collapse all

Change the storage format of a matrix and compare the storage requirements.

Create a random sparse matrix. The display of sparse matrices in MATLAB® omits all zeros and shows the location and value of nonzero elements.

rng default %for reproducibility S = sprand(8,8,0.3)

S = 8×8 sparse double matrix (15 nonzeros) (2,1) 0.0344 (7,1) 0.4456 (8,1) 0.7547 (2,2) 0.4387 (4,3) 0.7655 (7,3) 0.6463 (8,4) 0.2760 (1,6) 0.9502 (5,6) 0.1869 (8,6) 0.6797 (3,7) 0.3816 (4,7) 0.7952 (8,7) 0.6551 (6,8) 0.4898 (7,8) 0.7094

Convert the matrix to full storage. The MATLAB display of the matrix reflects the new storage format.

A = 8×8

     0         0         0         0         0    0.9502         0         0
0.0344    0.4387         0         0         0         0         0         0
     0         0         0         0         0         0    0.3816         0
     0         0    0.7655         0         0         0    0.7952         0
     0         0         0         0         0    0.1869         0         0
     0         0         0         0         0         0         0    0.4898
0.4456         0    0.6463         0         0         0         0    0.7094
0.7547         0         0    0.2760         0    0.6797    0.6551         0

Compare the storage requirements of the two formats:

Input Arguments

collapse all

Sparse matrix to convert, specified as a matrix. If S is already a full matrix, then A is identical to S.

Tips

Extended Capabilities

expand all

The full function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a