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: Fri, 6 Nov 2009 04:22:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <hd0899$mda$1@fred.mathworks.com>
References: <hcsqn1$ju4$1@fred.mathworks.com> <hct2gg$mm8$1@fred.mathworks.com> <hctf96$l7g$1@fred.mathworks.com> <hcthti$43u$1@fred.mathworks.com> <hcv3a6$ja$1@fred.mathworks.com> <hcv7sf$h4o$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 1257481321 22954 172.30.248.38 (6 Nov 2009 04:22:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Nov 2009 04:22:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1455324
Xref: news.mathworks.com comp.soft-sys.matlab:582918


thank you so much for your time!  it was very helpful!

"ade77 " <ade100a@gmail.com> wrote in message <hcv7sf$h4o$1@fred.mathworks.com>...
> 
> > hello,
> > i changed my data to separate the dates.  could you give me some tips on how to create a moving average filter?  i think it would be very useful for a variety of things in the future.
> > thanks!
> 
> averages = filter(ones(1,2),2,data);
> 
> the equation you are solving indirectly is :
> 2y(n) = x(n) + x(n-1)
> hence,
> y(n) = (x(n) + x(n-1))/2
> 
> If you need to find the moving average of 3 previous, then it will be
> averages = filter(ones(1,3),3,data);
> 
> for any case your data is the two columns of weights and Heigths.
> 
>     Note that for the first row, the moving average is (30 + 0)/2 = 15; etc
>     anything before the first row is assumed zero, unless you want to specify your initial condition.
>     
>     If you want the output to be in a special formating,:
>     and if your data if not confidential, you can click on my user name, and e mail the excel data to me or part of it to me, then I can properly reformat the excel file for you,and write the code for you.
>     
>     Note the reason I suggested you seperate the month,year and day is not only so that MATLAB can read the file easily, but also because, you can use the date functions in matlab to properly handle your situation.
> 
> If you need more help feel free to reply to this post.
>