MATLAB: Returning an Entire Row Based on the Max in a Column

MATLABmax value with corresponding row

Hi.
I'm trying to get the entire row based on the max value of a column. For example:
x = [5 6 6 9
7 3 2 4
3 12 8 4]
Now say I want the entire row belonging to the column 2 maximum value. I should get the row with 3 12 8 4 because 12 is the max value in column 2.
Is there a way to do this? I've tried the help and searching here and other places but cant seem to find it.

Best Answer

[~,imax]=max(x(:,2));
out = x(imax,:)