Find an index of maximum occurring element

조회 수: 2 (최근 30일)
Maia2022
Maia2022 2022년 6월 7일
답변: Maia2022 2022년 6월 8일
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