MATLAB: How to group rows based on unique value in the first column

group data

I have several excel worksheets with over 6000 rows of data in excel that go across multiple columns. In column 1 I have the number corresponding to an image (goes up sequentially) and in column 2 I have the cell number that goes up sequentially to a maximum number which varies image to image. I need to extract the maximum number of cells per image but I'm not sure how to script it in matlab.
Matrix Example to illustrate problem:
1 1
1 2
1 3
2 1
3 1
3 2
3 4
3 5
etc.
and I need an output that resembles
1 3
2 1
3 5
etc.

Best Answer

A = [1 1
1 2
1 3
2 1
3 1
3 2
3 4
3 5];
A1 = unique(A(:,1));
A2 = accumarray(A(:,1),A(:,2),[],@max)
output = [A1 A2]