Unitize[x]
gives 0 when x is zero, and 1 when x has any other numerical value.
Unitize
Unitize[x]
gives 0 when x is zero, and 1 when x has any other numerical value.
Examples
open all close allBasic Examples (3)
Convert numerical values to zero or one:
Unitize[Pi]Unitize[Sqrt[2] + Sqrt[3] - Sqrt[5 + 2Sqrt[6]]]Convert values less than 3 in magnitude to zero:
Unitize[E, 3]Unitize[Pi, 3]Replace values in a matrix with zeros or ones:
m = {{-2, 1, 0, 1}, {1, -2, 1, 0}, {0, 1, -2, 1}, {1, 0, -2, 1}};Unitize[m]Show a plot that emphasizes structure:
ArrayPlot[%]See Also
Related Guides
History
Text
Wolfram Research (2007), Unitize, Wolfram Language function, https://reference.wolfram.com/language/ref/Unitize.html.
CMS
Wolfram Language. 2007. "Unitize." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Unitize.html.
APA
Wolfram Language. (2007). Unitize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Unitize.html
BibTeX
@misc{reference.wolfram_2026_unitize, author="Wolfram Research", title="{Unitize}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Unitize.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_unitize, organization={Wolfram Research}, title={Unitize}, year={2007}, url={https://reference.wolfram.com/language/ref/Unitize.html}, note=[Accessed: 13-June-2026]}