MATLAB documentation says
"[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I."
But that does not seem to work. See below.
X = [2 8 4; 7 3 9];
[a,b] = max(X)
a =
7 8 9
b =
2 1 2
The indices could have been given as linear indices b = [ 2 3 6] so that X(b) would give the max values of columns of X in a.
It looks like an error in MATLAB because the doc says something but it does something different.
If you give max a matrix, it finds the maximum of each column. So $a = [7,8,9]$ and $b = [2,1,2]$ because the maximum of the first column is $7$, found in the second row, the maximum of the second column is $8$, found in the first row, and the maximum of the third column is $9$, found in the second row.