Find an index of maximum occurring element

2 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2022-6-7
See the first and third outputs of mode()

更多回答(1 个)

Maia2022
Maia2022 2022-6-8
Thank you very much.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by