Unitize

Unitize[x]
gives when x is zero, and when x has any other numerical value.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples (2)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]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »