フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

To remove duplicated matrices in different cell...

2 ビュー (過去 30 日間)
park minah
park minah 2011 年 10 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
first, let me describe my situation for following example.
cell {1} = [1 2 3 4;5 6 7 8]
cell {2} = [1 1 1 1;1 2 3 4]
cell {3} = [5 6 7 8;2 2 2 2]
I would like to know whether [1 2 3 4] of cell 1 is in other cells. In this example, it exists in cell{2}.
similary, I alse wonder [5 6 7 8] of cell 1 exists in other cells in the same way.
In breif, I wonder there is a fuction searching for a specific matrix in each cell.
And if it is possible, I want to remove these matrices in each cell.
So, I want results as follows.
cell 1 = [1 2 3 4;5 6 7 8]
cell 2 = [1 1 1 1]
cell 3 = [2 2 2 2]
Is it possible? What should I do? help me, plz.

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 14 日
c = {[1 2 3 4;5 6 7 8];
[1 1 1 1;1 2 3 4];
[5 6 7 8;2 2 2 2]};
n = cellfun('size',c,1);
C = cat(1,c{:});
[~, b] = unique(C,'rows','first');
y =mat2cell(ismember((1:size(C,1))',b),n,1);
out = cellfun(@(x,y)x(y,:),c,y,'un',0)
add use loop for
n = numel(c);
for j1 = 1:n-1
for j2 = j1+1:n
c{j2} = c{j2}(~ismember(c{j2},c{j1},'rows'),:);
end
end
  2 件のコメント
park minah
park minah 2011 年 10 月 14 日
andrei, thank you.
but I want not to use "cat".
because size of cell{1},cell{2} and cell{3} are actually very massive.
That is the reason why each matrix is stored by type of cell.
There is no way not to include "cat"?
Andrei Bobrov
Andrei Bobrov 2011 年 10 月 14 日
see 'add'

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by