How to get the most frequent value of vector on Matlab ?
1 次查看(过去 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?
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!