The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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


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!


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.