フィルターのクリア

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

1 回表示 (過去 30 日間)
Rebecca
Rebecca 2012 年 7 月 13 日
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!

採用された回答

Sean de Wolski
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 ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by