Unitize

Unitize[x]

gives 0 when x is zero, and 1 when x has any other numerical value.

Details

Examples

open allclose all

Basic Examples  (2)

Convert numerical values to zero or one:

Replace values in a matrix with zeros or ones:

Show a plot that emphasizes structure:

Applications  (1)

Determine if a sparse matrix is structurally symmetric:

Introduced in 2007
 (6.0)