Your wording is rather poor. It looks like what you want to do is for each unique value in the first column find the corresponding maximum in the second column. This is trivial to obtain with unique and accumarray: A = [8 4; 3 6; 2 7; 1 4; 2 3;2 1;3 1; 3 5; 8 6; 8 1];
[val, ~, subs] = unique(A(:, 1));
B = [val, accumarray(subs, A(:, 2), [], @max)]
Best Answer