필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Find Duplicates in cellarrays / use of subsindex for cellarrays

조회 수: 2 (최근 30일)
Léon
Léon 2012년 10월 31일
마감: MATLAB Answer Bot 2021년 8월 20일
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}

답변 (2개)

Honglei Chen
Honglei Chen 2012년 10월 31일
Is this what you are looking for?
X = A(IA,:)
Y = A(setdiff(1:3,A),:)

Andrei Bobrov
Andrei Bobrov 2012년 10월 31일
A = {'A',1;'A',2;'B',3};
[b b c] = unique(A(:,1),'first');
out1 = A(b,:);
out2 = A(setdiff(1:numel(c),b),:);

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by