spones
Replace non-zero entries with 1s.
Syntax
Section titled “Syntax”S = spones(R)Description
Section titled “Description”Returns a sparse matrix the same shape as R whose stored entries are all 1. The structural pattern is preserved — useful for capturing or comparing sparsity patterns between matrices.
Examples
Section titled “Examples”A = sparse([1 2; 3 0; 0 4]);spones(A) % stored entries replaced with 1s