Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Makrim
Makrim le 1 Avr 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).

Réponse acceptée

Joseph Cheng
Joseph Cheng le 1 Avr 2014
you can use mode()

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 1 Avr 2014
Modifié(e) : Azzi Abdelmalek le 1 Avr 2014
A=[1,2,2,4]
b=unique(A);
f=hist(A,b)
[~,idx]=max(f)
out=b(idx)
  1 commentaire
Joseph Cheng
Joseph Cheng le 1 Avr 2014
why do this when Matlab already has a function to do this like it does for mean and median?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by