Matlab group data by value. The numbers are generated randomly.
Matlab group data by value. It's trivial to add the row index T.