# How to binarize a matrix [closed]

I have this matrix

A = {{17/25, 3/25, 5/25, 0, 0}, {5/18, 5/18, 7/18,1/18, 0}, {4/21, 9/21, 4/21, 0, 4/21},
{0, 0, 3/4, 1/4, 0}, {3/4,1/4, 0, 0, 0}}


And i would like to have this matrix binarize, i wanted it to be like this

{{1, 1, 1, 0, 0}, {1, 1, 1,1, 0}, {1, 1, 1, 0, 1}, {0, 0, 1, 1, 0}, {1, 1, 0, 0, 0}}


Is any function in mathematica that does that? Or I have to programmate it? If so can un help me please?

Thanks (:

-

## closed as off-topic by Pickett, rasher, Jens, RunnyKine, gpapJun 11 '14 at 6:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Pickett, rasher, Jens, RunnyKine, gpap
If this question can be reworded to fit the rules in the help center, please edit the question.

Check out Unitize. Unitize@A –  Pickett Jun 11 '14 at 0:15
As Pickett says, there is a built-in function in Mathematica that does that: type in Unitize[A]. –  DumpsterDoofus Jun 11 '14 at 0:17
Also see Sign and Clip. –  Mr.Wizard Jun 11 '14 at 7:28
thanks, search for a while on help and didnt find anything, i was searching with the word matrix :/ –  Mariana da Costa Jun 11 '14 at 10:42

Several Ways. some of them are these:

Unitize@A


or

A /. x_ /; ! x == 0 -> 1


or

A /. x_ /; x != 0 -> 1

-
+1 for Unitize, though the other two solutions could benefit from an x_?NumericQ or similar (x_Integer in this case). If you were to use === and =!= instead of == and != they wouldn't work. –  Szabolcs Jun 11 '14 at 1:20
thanks for help :) –  Mariana da Costa Jun 11 '14 at 10:43

Just for fun:

(#/# /. Indeterminate -> 0 // Quiet) &@A

-