Path: news.mathworks.com!not-for-mail
From: "Anna Chen" <icedredtea@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: applying functions to grouped data
Date: Thu, 5 Nov 2009 03:03:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <hctf96$l7g$1@fred.mathworks.com>
References: <hcsqn1$ju4$1@fred.mathworks.com> <hct2gg$mm8$1@fred.mathworks.com>
Reply-To: "Anna Chen" <icedredtea@yahoo.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257390182 21744 172.30.248.38 (5 Nov 2009 03:03:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 03:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1455324
Xref: news.mathworks.com comp.soft-sys.matlab:582597


thanks for your response!  actually, i'm having a problem even getting the dates in correctly to matlab.  i'm importing a large file that has dates in the first column, and matlab will always separate it from the rest of the columns.  how would i reincorporate this first column and apply the moving average filter?  also, what if i wanted to apply some other moving function, other than averages?

thanks so much!


"ade77 " <ade100a@gmail.com> wrote in message <hct2gg$mm8$1@fred.mathworks.com>...
> you can use a moving average filter. Type doc filter.
> 
> Also, if you can include the year with your date, then it will be more appropriate, and you can change it to a date number.
> 
> Let me know if you need more help with the code.
> 
> > 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
> 
> 
> you can use a moving average filter. Type doc filter.
> 
> Also, if you can include the year with your date, then it will be more appropriate, and you can change it to a date number.
> 
> Let me know if you need more help with the code.