Path: news.mathworks.com!not-for-mail
From: "Tadros " <triad@ualberta.ca>
Newsgroups: comp.soft-sys.matlab
Subject: sum of consecutive integer
Date: Mon, 9 May 2011 21:42:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <iq9n3e$68t$1@newscl01ah.mathworks.com>
Reply-To: "Tadros " <triad@ualberta.ca>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1304977326 6429 172.30.248.35 (9 May 2011 21:42:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 May 2011 21:42:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2866150
Xref: news.mathworks.com comp.soft-sys.matlab:725936

Hi All;
I have a logical vector of zeros and ones, and I need to sum the consecutive ones and have the sum places at the end of each consecutive series of ones.
e.g.: 
Input = [0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1]
the desired output
output = [0 0 0 0 0 0 4 0 0 0 2 0 0 0 0 0 0 3]

Thanks