MATLAB Answers

How to identify duplicate elements index values in this array without deleting them

조회 수: 3(최근 30일)
sakshi chopra
sakshi chopra 2021년 7월 25일
댓글: sakshi chopra 2021년 7월 26일
A=[53 54 80 1
21 43 12 0
27 71 14 0
52 55 70 23
36 69 26 0
46 66 38 0
68 78 60 0
59 3 48 0
74 7 42 0
42 17 74 0
67 30 64 0
64 35 67 0]
how to identify duplicate elements index values in this array without deleting them like 67 is repeated twice and so as 64

채택된 답변

Image Analyst
Image Analyst 2021년 7월 25일
Try this:
A = [53 54 80 1
21 43 12 0
27 71 14 0
52 55 70 23
36 69 26 0
46 66 38 0
68 78 60 0
59 3 48 0
74 7 42 0
42 17 74 0
67 30 64 0
64 35 67 0]
minValue = min(A(:))
maxValue = max(A(:))
[counts, edges] = histcounts(A, minValue : maxValue)
for k = 1 : length(counts)
if counts(k) >= 2
fprintf('%f is in there %d times.\n', edges(k), counts(k));
end
end
You'll see:
0.000000 is in there 10 times.
42.000000 is in there 2 times.
64.000000 is in there 2 times.
67.000000 is in there 2 times.
74.000000 is in there 2 times.
  댓글 수: 3

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by