Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
I have a cell that is 255x1, 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!

Risposta accettata

Sean de Wolski
Sean de Wolski il 13 Lug 2012
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

Più risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by