MATLAB: Finding number in a column of a matrix and retrieving corresponding number from adjacent column

matrix indexing

Hi I am having issues with indexing from matrix. Can you please advise on the question below? e.g. I have a matrix CV = [1 11; 3 13; 4 14; 5 17; 8 6]; I want to find the max value in column 1 (which in this case is 8) and get the corresponding value in the adjacent column (which is 6 in this case).
Thanks SATEJ

Best Answer

Ask max for its second output, the index of the maximum value. (This works for min as well.)
Example:
CV = [1 11; 3 13; 4 14; 5 17; 8 6];
[CVmax,idx] = max(CV(:,1), [], 1);
result = [CVmax, CV(idx,2)]
produces:
result =
8 6
as desired.