Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Makrim
Makrim el 1 de Abr. de 2014
Editada: Azzi Abdelmalek el 1 de Abr. de 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).

Respuesta aceptada

Joseph Cheng
Joseph Cheng el 1 de Abr. de 2014
you can use mode()

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Abr. de 2014
Editada: Azzi Abdelmalek el 1 de Abr. de 2014
A=[1,2,2,4]
b=unique(A);
f=hist(A,b)
[~,idx]=max(f)
out=b(idx)
  1 comentario
Joseph Cheng
Joseph Cheng el 1 de Abr. de 2014
why do this when Matlab already has a function to do this like it does for mean and median?

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by