Find repeated rows within each entry of a cell and delete all repetitions
1 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
Sean de Wolski
2012-7-13
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!