I have array of 2500 elements.i would to find a number from this array which is maximum times in array and i don't know that number
조회 수: 1 (최근 30일)
이전 댓글 표시
I have array of 2500 elements.i would to find a number from this array which is maximum times in array and i don't know that number
댓글 수: 0
채택된 답변
Matthew Eicholtz
2012년 11월 5일
I'm sure there is a one-liner that can solve your problem, but here is one option:
Let
A = randi(10,[2500 1]); % 2500x1 vector with all random integers <= 10
B = unique(A);
[~,j] = max(arrayfun(@(x) sum(A==x),B));
Then the value that appears the most in A is given by B(j).
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!