Illustration of Minimum and Maximum Value
Both of these functions also return the index of the minimum or maximum value; when there is more than one occurrence, it returns the first. For illustration, in the data set below, 10 is the maximum value; it is found in three elements in the vector but the index returned is the first element in which it is found (that is 2):
>> x = [9 10 10 9 8 7 3 10 9 8 5 10];
>> [maxval, maxind] = max(x)
maxval =
10
maxind =
2