Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sums and loops
Date: Tue, 8 Jan 2008 16:24:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <fm0832$q4k$1@fred.mathworks.com>
References: <flkv6k$fa$1@fred.mathworks.com> <fll0jh$7rt$1@fred.mathworks.com> <flldtq$1bh$1@fred.mathworks.com> <fllfk7$m4m$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1199809442 26772 172.30.248.37 (8 Jan 2008 16:24:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 8 Jan 2008 16:24:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1226852
Xref: news.mathworks.com comp.soft-sys.matlab:444899




Thanks for all, it worked great :)

"Peter Bone" <peterbone@hotmail.com> wrote in message
<fllfk7$m4m$1@fred.mathworks.com>...
> "Dave " <bocconiluck@yahoo.com> wrote in message
> <flldtq$1bh$1@fred.mathworks.com>...
> > 
> > thanks for the reply, i explain the question further 
> > 
> > p=[1 2 3 4 5 6 7 8 9]'
> > 
> > we need a code that sums elements in p for ex the first
> > three elements at a time resulting in a new column s
> > 
> > s=[6 15 24]'
> > 
> > (6=1+2+3 .. 15=4+5+6 ... 24= 7+8+9 ...)
> > 
> > I tried reshape in didnt work but thanks for the input
> 
> reshape works fine
> 
> p = [1 2 3 4 5 6 7 8 9]';
> blockSize = 3;
> s = sum(reshape(p,[blockSize length(p)/blockSize]))'
>