Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Selecting the most repeated value

Asked by med-sweng on 27 Apr 2013

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.

0 Comments

med-sweng

Products

No products are associated with this question.

1 Answer

Answer by Andrei Bobrov on 27 Apr 2013
out = b((max(a) == a));

0 Comments

Andrei Bobrov

Contact us