MATLAB Answers

Makrim
0

How to get the most frequent value of vector on Matlab ?

Asked by Makrim
on 1 Apr 2014
Latest activity Edited by Azzi Abdelmalek
on 1 Apr 2014
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 Comments

Sign in to comment.

Products

2 Answers

Answer by Joseph Cheng
on 1 Apr 2014
 Accepted Answer

you can use mode()

  0 Comments

Sign in to comment.


Answer by Azzi Abdelmalek
on 1 Apr 2014
Edited by Azzi Abdelmalek
on 1 Apr 2014

A=[1,2,2,4]
b=unique(A);
f=hist(A,b)
[~,idx]=max(f)
out=b(idx)

  1 Comment

why do this when Matlab already has a function to do this like it does for mean and median?

Sign in to comment.