How to get the most frequent value of vector on Matlab ?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a vector A that contains let say [1,2,2,4]. I am looking for a way to get the most frequent value on A (here 2).
0 件のコメント
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2014 年 4 月 1 日
編集済み: Azzi Abdelmalek
2014 年 4 月 1 日
A=[1,2,2,4]
b=unique(A);
f=hist(A,b)
[~,idx]=max(f)
out=b(idx)
1 件のコメント
Joseph Cheng
2014 年 4 月 1 日
why do this when Matlab already has a function to do this like it does for mean and median?
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!