MATLAB: How to delete the duplicate rows in cell based on a particular column

cellunique

The input is:
A={[1 2 3] [2 3] [1 2 3];[2 5 8] [3 4] [1 2 3];[2 5 4] [2 3] [1 2 3];[1 2 5] [3 4] [1 2 3]};
based on the duplication in the 2nd column,the output will be:
B={[2 5 4] [2 3] [1 2 3];[1 2 5] [3 4] [1 2 3]};
How can I do that?

Best Answer

This assumes the second column always contains vectors of the same length, and also that you want to keep only the last occurence.
[~,idx]=unique(cell2mat(A(:,2)),'rows','last');
B=A(idx,:);