Find an index of maximum occurring element

4 visualizaciones (últimos 30 días)
Maia2022 el 7 de Jun. de 2022
Respondida: Maia2022 el 8 de Jun. de 2022
I'd like to find the value tht has the maximum occurence is a array
Ex: A = [ 1 2 3 1 1 6 3 4 2 2 1 1 1 ];
x = unique(A);
N = numel(x);
[u, ~, uidx] = unique(A(:));
counts = accumarray(uidx, 1);
Those solutions give the number of occurences but I'd like to get the indices and the values of that value with max occurrences.
Thank you

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Jun. de 2022
See the first and third outputs of mode()

Más respuestas (1)

Maia2022 el 8 de Jun. de 2022
Thank you very much.


Más información sobre Data Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by