MATLAB: Find repeated rows within each entry of a cell and delete all repetitions

cell arraysmatricesmatrix manipulation

I have a cell that is 255×1, and each entry in the cell is nx3. For all entries of the cell, if a row of values is repeated in the list, I need to delete all appearances of it. Order does not matter (for example, in cell{1,1}, if [45 23 98] and [98 45 23] are present, both of those rows need to be deleted from the list).
Any help with this is appreciated! Thank you!

Best Answer

This oughtta do it:
function C2 = examplecelluniqueage
C = {[1 1 1; 1 7 8; 8 7 1];rand(4,9);magic(2);ones(10)}; %example cell
C2 = cellfun(@removeDups,C,'uni',false); %apply dup remover
function y = removeDups(x)
[uv,~,idxu] = unique(sort(x,2),'rows'); %unique rows of sorted rows
[n,idxh] = histc(idxu,1:numel(uv)); %how many occurences of each row?
idxk = idxu(n(idxh)==1); %keep the ones that occured once
y = x(idxk,:); %extract