findout the repeating element and the no of time of repeated in a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
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
2015 年 5 月 26 日
Are the numbers always integers? Or can they be fractional/irrational numbers? (It makes a difference.)
回答 (1 件)
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!