Path: news.mathworks.com!newsfeed-00.mathworks.com!oleane.net!oleane!news.ecp.fr!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 12:32:02 -0600
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <hcv60m$pke$1@news.eternal-september.org>
References: <hcv1e7$3ua$1@fred.mathworks.com> <hcv26o$q72$1@news.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX19pm6SOJBD2FQJ+922mpfR72lYWQmnaRRvshT9U705x8r2F3BUmRou4v11aQVXsaTcsHGJPFcgl61kKB2qrBgW/6rFOQhrpPIyz5Kvmlsgvr2EjseTlmSIYJ6cQ8LOpmeKOsmhkEy6Iwg==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Thu, 5 Nov 2009 18:37:10 +0000 (UTC)
In-Reply-To: <hcv26o$q72$1@news.eternal-september.org>
X-Auth-Sender: U2FsdGVkX1/KbZy13xVOGK3xDdw43EugzeRyVEY13Dw=
Cancel-Lock: sha1:zU/TeXHwKTOL0pnIF30mTBbI6lw=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:582827


dpb wrote:
> 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., ...

Should have been

avg = mean(x(idx,:));

of course...

--