You are setting location to a scalar. It can never have a value other than a scalar. In particular, it cannot represent multiple values.
Also, location will, at the end of the process, contain the last value assigned. In your code that is not the location of the maximum value, but rather the location of the last value that is greater than the first value. In your test case the maximum value is in the last location, and so you get that location. Not so in general.
__________________
� � � � Tom Gutman