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

조회 수: 2 (최근 30일)
navan
navan 2015년 5월 26일
댓글: Image Analyst 2015년 5월 26일
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
Image Analyst
Image Analyst 2015년 5월 26일
Are the numbers always integers? Or can they be fractional/irrational numbers? (It makes a difference.)

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 5월 26일
편집: Andrei Bobrov 2015년 5월 26일
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);

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by