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!