How to print duplicate (repeated) value from an array?
Ältere Kommentare anzeigen
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 Kommentare
Dr. Hareesha N G
am 4 Jan. 2018
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 4 Jan. 2018
Bearbeitet: Image Analyst
am 4 Jan. 2018
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.
1 Kommentar
Dr. Hareesha N G
am 4 Jan. 2018
Poornimadevi P
am 26 Jan. 2018
0 Stimmen
hi, please help me to find duplication in sequence of image and send me a code .
1 Kommentar
Image Analyst
am 26 Jan. 2018
Use diff().
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!