From help-request at octave dot org Sun Feb 6 10:59:26 2005 Subject: Re: subsums From: "Dmitri A. Sergatskov" To: brumen at hispeed dot ch CC: help at octave dot org Date: Sun, 06 Feb 2005 10:01:48 -0700 Gorazd Brumen wrote: > Hi, > > How do you form a vector of subsums of a certain vector without the for > loop? > Example: > Let x = [1 2 3 4 5 6 7 8 9 10] > I want to get a vector that would have as entries > sum([1 2 3 4 5]) and sum ([6 7 8 9 10])? > octave:1> x = [1 2 3 4 5 6 7 8 9 10] x = 1 2 3 4 5 6 7 8 9 10 octave:2> y=reshape(x,5,2) y = 1 6 2 7 3 8 4 9 5 10 octave:3> z=sum(y) z = 15 40 > Thanks, > g. > > Regards, Dmitri. -- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------