MATLAB: A mix of sorting, unique and deleting bits of an array

sortunique

I have an array of frequencies (1st column) and their amplitudes (2nd column).
Each entry has a different amplitude, but there are several occurrences of each frequency.
I want to be able to use the highest amplitude of each frequency. Just ignoring or deleting the rest.
Ive tried using the unique rows function, and this sorts them all so that similar frequencies are together with the highest amplitude one first, but how would i go about deleting the lower amplitude ones.
Thanks

Best Answer

Y = sortrows(X);
[uniqY, index] = unique(Y(:, 1), 'last');
Now Y(index, :) contains the largest values in the 2nd column.
The order of the results might change in the future, see Answers: Change of set functions in the future. Unfortunately a workaround can be required to ensure a specific order.