Back to Sparse Matrices
sprand
Sparse uniformly distributed random matrix
Syntax
S = sprand(m, n, density)
Description
Generates an m-by-n sparse matrix with approximately density*m*n uniformly distributed nonzero entries on [0,1).
Parameters
| Name | Description |
|---|---|
| m | Number of rows |
| n | Number of columns |
| density | Approximate density (0 to 1) |
Returns
Sparse random matrix
Examples
Try It
>> S = sprand(100, 100, 0.05)