Borrar filtros
Borrar filtros

Info

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

Find Duplicates in cellarrays / use of subsindex for cellarrays

2 visualizaciones (últimos 30 días)
Léon
Léon el 31 de Oct. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hello,
I know how to find the duplicates in cellarrays but how can I reference the cellarray to filter out the duplicated or vice versa get a list with the duplicates etc.?
This is actually what I try to achieve, but the last line doesn't work on cellarrays, so what is the best way in this case? Thank you very much for your help beforehand:
A = {'A',1;'A',2;'B',3}
[C,IA,IC] = unique(A(:,1),'R2012a');
IA(A)
The result should be the following:
X = {'A',1;'B',3}
Y = {'A',2}

Respuestas (2)

Honglei Chen
Honglei Chen el 31 de Oct. de 2012
Is this what you are looking for?
X = A(IA,:)
Y = A(setdiff(1:3,A),:)

Andrei Bobrov
Andrei Bobrov el 31 de Oct. de 2012
A = {'A',1;'A',2;'B',3};
[b b c] = unique(A(:,1),'first');
out1 = A(b,:);
out2 = A(setdiff(1:numel(c),b),:);

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