Back to Sparse Matrices
spalloc
Allocate space for sparse matrix
Syntax
S = spalloc(m, n, nz)
Description
Creates an m-by-n all-zero sparse matrix with space preallocated for nz nonzero elements. Returns an empty sparse matrix (JS sparse matrices auto-resize).
Parameters
| Name | Description |
|---|---|
| m | Number of rows |
| n | Number of columns |
| nz | Number of nonzero elements to allocate (hint) |
Returns
Empty sparse matrix
Examples
Try It
>> S = spalloc(10, 10, 50)