Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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!

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 13 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by