Back to Sparse Matrices
spconvert
Import sparse matrix from triplet data
Syntax
S = spconvert(D)
Description
Converts a matrix D with rows [i j v] into a sparse matrix. Row indices are in column 1, column indices in column 2, values in column 3. The last row may specify the matrix dimensions as [m n 0].
Parameters
| Name | Description |
|---|---|
| D | Dense matrix with columns [i, j, v] |
Returns
Sparse matrix
Examples
Try It
>> D = [1 1 10; 2 2 20; 3 3 30]; S = spconvert(D)