MATLAB: How to group string datasets

mergetext array

I have the following dataset:
ID_Ref SP MD FI
123456 [] [] 'A+'
234567 [] [] 'A'
234567 [] [] 'A'
345678 [] [] 'A+'
345678 [] 'Aa2' []
456789 [] [] 'A+'
456789 [] 'Aa2' []
456789 AA+ 'Aa2' []
All the column arrays are string.
How do I group the above dataset by unique ID_Ref to read:
ID_Ref SP MD FI
123456 [] [] 'A+'
234567 [] [] 'A'
345678 [] 'Aa2' 'A+'
456789 AA+ 'Aa2' 'A+'
Apologies if you are unable to read this table in this message box.

Best Answer

Edit
ratings={123456 [] [] 'A+'
234567 [] [] 'A'
234567 [] [] 'A'
345678 [] 'Aa2' 'A+'
456789 'AA+' 'Aa2' 'A+'
345678 [] 'Aa2' []
456789 [] [] 'A+'
456789 [] 'Aa2' []
456789 'AA+' 'Aa2' []}
A=cellfun(@num2str,ratings,'un',0);
c1=cell2mat(ratings(:,1));
[ii,jj,kk]=unique(c1,'stable');
cc=size(A,2);
out=cell(numel(ii),cc);
for k=1:numel(ii)
idx=find(kk==k);
out{k,1}=ii(k,1);
for mm=2:cc
a=A(idx,mm);
b=unique(a);
out{k,mm}=b{end};
end
end
out(cellfun(@isempty ,out))={[]}