Filter löschen
Filter löschen

findout the repeating element and the no of time of repeated in a matrix

1 Ansicht (letzte 30 Tage)
navan
navan am 26 Mai 2015
Kommentiert: Image Analyst am 26 Mai 2015
i do have a matrix
A=[1,2,3,4,5,5,6,7,8,8,8, 9]
how can i find the repeating values and the no of times it is repeated. answer i expected is
repeatvalues=[5, 8]
Nooftimerepeated=[2,3]
  1 Kommentar
Image Analyst
Image Analyst am 26 Mai 2015
Are the numbers always integers? Or can they be fractional/irrational numbers? (It makes a difference.)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 26 Mai 2015
Bearbeitet: Andrei Bobrov am 26 Mai 2015
A=[1,2,3,4,5,5,6,7,8,8,8, 9]
a = unique(A);
b = histc(A,a);
t = b > 1;
repeatvalues = a(t);
Nooftimerepeated = b(t);

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by