2018/07/30

Matlab: Maximum element and index

To the the maximum value of an array and the index of the maximum value, use the max() function  as below:

>> a = [1 4 5 7 3 2]

a =

     1     4     5     7     3     2

>> [max, index] = max(a)

max =

     7


index =

     4

>> 

Reference:

max - Maximum elements of an array (MathWorks)