Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Collapse/Compress Long-form Data
Replies: 2   Last Post: Apr 29, 2013 3:58 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Cory

Posts: 33
Registered: 10/4/11
Collapse/Compress Long-form Data
Posted: Apr 29, 2013 3:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.