Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

To remove duplicated matrices in different cell...

1 visualización (últimos 30 días)
park minah
park minah el 14 de Oct. de 2011
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 14 de Oct. de 2011
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 comentarios
park minah
park minah el 14 de Oct. de 2011
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 el 14 de Oct. de 2011
see 'add'

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by