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

New to MATLAB?

Problem 2200. counting groups!

Created by Chris E.

This problem is about counting groups.

Example

If you have x:

 x = [0.8 0.8 0.8 0.3 0.3 0.4 0.5 0.6 0.6 0.9]

then all 0.8's being first in line, get a value of 1, all 0.3's get a value of 2, all 0.4's a value of 3 and so on, till the output y is:

 y = [1 1 1 2 2 3 4 5 5 6]

That's it!

Please note, to make it easier, the list will be "pre-sorted".

Problem Group

Solution Statistics

36 correct solutions 15 incorrect solutions
Last solution submitted on May 29, 2015