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:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Replace values in a matrix with zeros or ones:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Show a plot that emphasizes structure:

In[3]:=
Click for copyable input
Out[3]=

Applications  (1)

See Also

UnitStep  KroneckerDelta  Boole  Sign  DiracDelta  Clip

Introduced in 2007
(6.0)