Create a sparse matrix from the full matrix or row, column, value triplets. If a is a full matrix, convert it to a sparse matrix representation, removing all zero values in the process.
Given the integer index vectors i and j, a 1-by-
nnz
vector of real of complex values sv, overall dimensions m and n of the sparse matrix. The argumentnzmax
is ignored but accepted for compatibility with Matlab. If m or n are not specified their values are derived from the maximum index in the vectors i and j as given by m= max (
i)
, n= max (
j)
.Note: if multiple values are specified with the same i, j indices, the corresponding values in s will be added.
The following are all equivalent:
s = sparse (i, j, s, m, n) s = sparse (i, j, s, m, n, "summation") s = sparse (i, j, s, m, n, "sum")Given the option "unique". if more than two values are specified for the same i, j indices, the last specified value will be used.
sparse(
m,
n)
is equivalent tosparse ([], [], [],
m,
n, 0)
If any of sv, i or j are scalars, they are expanded to have a common size.
See also: full