Suppose:
A{1}=
2 3 1 2
2 1 1 3
2 3 2 4
2 5 2 5
2 6 2 6
2 2 5 2
How can I find the duplicate value and their indices for column 3? Resultant should be: Value: 1,2 Indices: Can be 1,3 --OR-- 1,2,3,4,5.
I tried unique but it returns 5 as well, which is something I don't want.
Gracias.

 채택된 답변

Jos (10584)
Jos (10584) 2014년 6월 25일

1 개 추천

X = A{1}
X = X(:,3) % just column 3
[a,i,j] = unique(X) % find all unique elements
n = histc(j,1:numel(a)) % frequency
tf = n > 1 % Which occur more than once?
required result = a(tf) % select those

댓글 수: 2

RDG
RDG 2014년 6월 25일
Thanks for the prompt reply. What about the indices of those value? (2nd part of the question)
Jos (10584)
Jos (10584) 2014년 6월 25일
requiredindices = i(tf)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

RDG
2014년 6월 25일

댓글:

2014년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by