Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: average every 12th row of matrix
Date: Thu, 05 Nov 2009 11:26:55 -0600
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <hcv26o$q72$1@news.eternal-september.org>
References: <hcv1e7$3ua$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX19Aice3UMTh0dVeauWvlLlhsdYfOXfBCMDA9Jg1XyZiudIYbq8n1pYN3C0GFkHAzCjtFMnQX/uKWRRuNFPKwX7A5JfBs4RyDqamVvsRWv2n3N0d3lerkmLEKRUkxbFzOsPsN7KIa+5Z8Q==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Thu, 5 Nov 2009 17:32:09 +0000 (UTC)
In-Reply-To: <hcv1e7$3ua$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX183JX7TF5eKIla6ZULryyWrxcgkpACw36k=
Cancel-Lock: sha1:pT/HAfqLGVFU63GS5NWzjxRcyjc=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:582809


Nix Nicholson wrote:
> 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.
...

idx=1:12:length(x);
avg = mean(idx,:);

Salt to suit on selecting starting month, etc., ...

--