Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Cory
Posts:
33
Registered:
10/4/11


Collapse/Compress Longform Data
Posted:
Apr 29, 2013 3:39 PM


Hi MATLABers,
I have some data that can be put into groups of different sizes. For instances, I might have an nX2 vector where the first column is a group number and the second is a value:
[1 2; 1 3; 1 1; 2 6; 2 10; 3 9; 3 11; 3 0]
Is there an easy/fast/vectorized way to get MATLAB to take the minimum (maximum, sum, mean...) by group number? For the minimum, e.g, the result would be:
[1 1; 2 6; 3 0]
Obviously I could use loops, but I'm curious if there's a better solution. Thanks!
Cory



