MATLAB: Table maximum value column

table maximum value column depending on the values of the other columns

Hi, I have this table
0 0
0 0
0,0100000000000000 0
0,0100000000000000 1
0,0100000000000000 2
0,0200000000000000 0
0,0200000000000000 1
0,0200000000000000 2
but the table that I want is this one
0 0
0.01 2
0.02 2
the second column is the highest value of each number (0 0.01 0.02)
if someone can help me I would really appreciate because I am a little bit stuck in this problem I do not know even how to start to solve it
Thanks in advance for your time
Luca

Best Answer

A=[0 0
0 0
0.0100000000000000 0
0.0100000000000000 1
0.0100000000000000 2
0.0200000000000000 0
0.0200000000000000 1
0.0200000000000000 2];
[g,ii] = findgroups(A(:,1));
out = [ii,splitapply(@max,A(:,2),g)];
or
[ii,~,g] = unique(A(:,1));
out = [ii,accumarray(g,A(:,2),[],@max)];
Related Question