Find an index of maximum occurring element

2 Ansichten (letzte 30 Tage)
Maia2022
Maia2022 am 7 Jun. 2022
Beantwortet: Maia2022 am 8 Jun. 2022
Hi,
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

Akzeptierte Antwort

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

Weitere Antworten (1)

Maia2022
Maia2022 am 8 Jun. 2022
Thank you very much.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by