main.m596 chars19 lines
Explanation:
A
and B
. We want to find the location of the maximum value in A
where the corresponding value in B
equals 0.max_val
to negative infinity and max_loc
to [0 0]
.A
and B
. If the element in B
equals 0 and the element in A
is greater than max_val
, we update max_val
and max_loc
.Note: If there are multiple locations where the value is the maximum, this code will only return one of those locations.
gistlibby LogSnag