How to print duplicate (repeated) value from an array?
이전 댓글 표시
Dear experts,
I have to print the duplicate (repeated) value from the following array. Please help me.
104.96
81.01
-35.21
-150.76
145.22
104.96
20.62
-90.79
댓글 수: 2
Dr. Hareesha N G
2018년 1월 4일
채택된 답변
추가 답변 (2개)
Image Analyst
2018년 1월 4일
편집: Image Analyst
2018년 1월 4일
Here is one way:
v = [...
104.96
81.01
-35.21
-150.76
145.22
104.96
20.62
-90.79]
distances = pdist2(v, v) % In Stats toolbox
% Find where distances = 0
[rows, columns] = find(distances == 0)
for k = 1 : length(rows)
if rows(k) ~= columns(k) % Ignore diagonals
fprintf('Element at row %d (%f) is a repeat.\n', rows(k), v(rows(k)));
end
end
It shows:
Element at row 6 is a repeat.
Element at row 1 is a repeat.
Poornimadevi P
2018년 1월 26일
0 개 추천
hi, please help me to find duplication in sequence of image and send me a code .
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!