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: applying functions to grouped data
Replies: 7   Last Post: Nov 5, 2009 11:22 PM

Advanced Search

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

Posts: 26
Registered: 6/21/06
applying functions to grouped data
Posted: Nov 4, 2009 4:12 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

hello,
i'm a fairly inexperienced matlab user, and i had a question about applying functions to data based on certain groupings. for example, let's say i have the following data set:

Date Height Weight
1/31 30 20
1/31 23 43
1/31 20 50
2/28 10 40
2/28 40 30
3/31 90 40
3/31 10 30
3/31 40 60

i want to compute 2-month rolling averages of height and weight. so on 2/28, i want the averages of heights on 1/31 and 2/28, and averages of weights on 1/31 and 2/28. For 3/31, i want to do the same for 3/31 and 2/28. I will end up with something like this:

Date Rolling2-monthHeight Rolling2-monthWeight
2/28 24.6 36.6
3/31 38 40

What would be the best way to do this? I've been trying to use while loops, but the date format kind of messes that up. Thanks so much for your help!



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2009. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Goodwin College of Professional Studies.