MATLAB: Find set of values that are unique to the values in another column

arraymathematicsMATLABmatricesmatrixmatrix arraymatrix manipulation

I have a matrix like the following.
2 3
2 6
2 8
4 5
5 9
5 39
5 6
I need to do operations on numbers in the second column based on the values in the first column. It should be for the unique vaue "2", mean of (3,6,8) etc. Any help is appreciated. Thanks

Best Answer

% Mqtrix
A =[2 3;
2 6
2 8
4 5
5 9
5 39
5 6]
% Get unique values on first collumn
un = unique(A(:,1)); % un = [2 4 5]
% Output
A(A(:,1)==un(1),2)