Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: sums and loops
Date: Fri, 4 Jan 2008 09:44:52 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <flkv6k$fa$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 1199439892 490 172.30.248.35 (4 Jan 2008 09:44:52 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Jan 2008 09:44:52 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 875558
Xref: news.mathworks.com comp.soft-sys.matlab:444302



I am stuck writing a loop, any help??

The problem:
z is a vector of 100 numbers
i would be generating a col vector p which sums the first 5
elements of z then the second 5 elements and so on (non
overlapping) , z will have 20 elements. 

I tried this but :(

for z=1:20
    for i=1:100;
        j=(i+2):100;
        p(z)=sum(sp(i:j));
        end
    end

end 

thanks for any help