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).

采纳的回答

Joseph Cheng
Joseph Cheng 2014-4-1
you can use mode()

更多回答(1 个)

Azzi Abdelmalek
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)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by