MATLAB: Finding maximum value of a column in a matrix

maximum-column value

Hello, I would really appreciate any help I can get here. I have a 3×5 matrix, A= [4 9 7 8 8; 2 1 0 3 5; 6 3 3 2 1]. I want to find the maximum value in column 1 and have the output display the corresponding row values of that maximum value. That is B = [6 3 3 2 1]. Please how can I achieve that? Thank you.

Best Answer

[~,x] = max(A(:,1));
B = A(x,:);