|
|
applying functions to grouped data
Posted:
Nov 4, 2009 4:12 PM
|
|
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!
|
|