Replace maximum of array by row with 1, otherwise 0

Published: 14/03/2018
Replace maximum of array by row with 1, otherwise 0
Source: STACKOVERFLOW.COM

Suppose, we have a A = [3 4 5; 7 1 4] . I want to make it as [0 0 1; 1 0 0] . I tried this: maxa = max(A(:)); A(A==maxa) = 1 ; This is replacing only maximum value of matrix by one. I need maximum value of each row replaced by one and other values by zero.

Read more
Related news
Comment
FACEBOOK