sp = sparse(M)
sp = sparse(m, n)
sp = sparse(I, J, V)
sp = sparse(I, J, V, m, n)
sp = sparse(I, J, V, m, n, nz)
| Parameter | Description |
|---|---|
| M | a matrix: double or logical. |
| m | an integer value: rows dimension. |
| n | an integer value: columns dimension |
| I | a vector. |
| J | a vector. |
| V | a vector. |
| nz | an integer value: storage allocation for nonzero elements. |
| Parameter | Description |
|---|---|
| S | a single. |
sparse is used to build a sparse matrix. Only non-zero entries are stored.
If M is a full matrix, sparse converts it to a sparse matrix representation, removing all zero values.
If nz is not specified, sparse uses as default value: nz = max([numel(i), numel(j), numel(v)])
If multiple values are specified with the same i, j indices, the associated value will be the sum of the values at the repeated index.
sp = sparse(eye(3,3))
sp = sparse(3, 3)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V)
size(sp)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V, 5, 4)
size(sp)
nnz(sp)
nzmax(sp)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V, 5, 4, 10)
size(sp)
nnz(sp)
nzmax(sp)
| Version | Description |
|---|---|
| 1.0.0 | initial version |