Selecting the most repeated value

조회 수: 1 (최근 30일)
med-sweng
med-sweng 2013년 4월 27일
Say we have the following matrix:
> x=[2 3 2; 4 2 3; 4 2 3; 6 43 32];
And, we do the following, such that `a` shows how many time each number was repeated in `x`:
> [a,b]=hist(x(:),unique(x))
a =
4 3 2 1 1 1
b =
2
3
4
6
32
43
How can we select the value which is repeated most? Which would be in our example the value `2`.
Thanks.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 4월 27일
out = b((max(a) == a));

카테고리

Help CenterFile Exchange에서 Dynamic System Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by