Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: average every 12th row of matrix
Date: Thu, 5 Nov 2009 17:30:36 +0000 (UTC)
Organization: Xoran Technologies
Lines: 9
Message-ID: <hcv23r$ftq$1@fred.mathworks.com>
References: <hcv1e7$3ua$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257442236 16314 172.30.248.35 (5 Nov 2009 17:30:36 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 17:30:36 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:582808


"Nix Nicholson" <linznix@gmail.com> wrote in message <hcv1e7$3ua$1@fred.mathworks.com>...
> Hi: Beginner question - I have 7 years of some monthly data fields and I want to compute the average for each month over the 7 year period. I can do it by specifying row numbers but how could I do this so that come next year, when i have 8 years data I can just change a scaler value for year number and it will recompute a new average?
> basically how do i compute a mean of every nth row, in my case every 12th.

Instead of organizing your data as a vector, you can organize it as an Nx12 matrix A where N is the number of years. Then do

MonthlyMeans=mean(A,1);

When you have N=8, just add a row and do the same thing.