If you want the maximum of a specific column, you only pass that column to max
, or you select the column from the resulting list of indices.
%# create an array
A = magic(4)
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
%# select the maximum of column 3
[maxValue, rowIdx] = max(A(:,3),[],1)
maxValue =
15
rowIdx =
4
If you need to look up a corresponding value in another array, you use otherArray(rowIdx,3)