finding duplicates
조회 수: 380 (최근 30일)
이전 댓글 표시
A=[ 1 1 2 2 3 3 3];
unique(A)=[1 2 3]; but I want to find the duplicates that are not the first occurrence. i.e x=[2 4 6 7]; I typed help unique but I couldn't figure out if I and J reported by this function helps with my purpose.I know that I can program it but i want to be as efficient as possible in my codes to reduce the running time.
댓글 수: 0
채택된 답변
the cyclist
2011년 8월 5일
Here is one way:
[uniqueA i j] = unique(A,'first');
indexToDupes = find(not(ismember(1:numel(A),i)))
댓글 수: 0
추가 답변 (1개)
Jan
2011년 8월 5일
Another solution:
A = [1 1 2 2 3 3 3];
[U, I] = unique(A, 'first');
x = 1:length(A);
x(I) = [];
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!