Index of max and min value in an array

The built-in max function has this functionality when two output arguments are specified:

a = [1 2 999 3];
[the_max, index_of_max] = max(a)

the_max =

   999


index_of_max =

     3

Likewise for min.

Leave a Comment