MATLAB: How to filter duplicate entries

data acquisitionData Acquisition ToolboxMATLABStatistics and Machine Learning Toolbox

Hi,
I have below entries (cell array matrix),
FirstEntry SecondEntry Index Score
A B 5 25
C D 62 8
C K 31 2
B A 6 25
K C 9 2
The entry A & B (in row 1)is same as B & A(in row 4) (without consider its first entry or second entry), I only want to keep one entry for this kind of entries. Likewise, row 3 (c & K) is same as row 5 (K & C)
My desired output:
FirstEntry SecondEntry Index Score
A B 5 25
C D 62 8
C K 31 2
Kindly some one help, many thanks in advance,

Best Answer

Your original cell array is named 't'.
t = {
'A' 'B' 5 25
'C' 'D' 62 8
'C' 'K' 31 2
'B' 'A' 6 25
'K' 'C' 9 2};
'unqIdx' is an index of row numbers of 't' that are unique.
'desired' is your unique array without duplicates.
[~, unqIdx] = unique(cellfun(@strcat, sort(t(:,[1,2])')'), 'rows');
desired = t(unqIdx, :);