```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sum of consecutive integer
Date: Mon, 9 May 2011 23:32:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 17
Message-ID: <iq9thl\$k9s\$1@newscl01ah.mathworks.com>
References: <iq9n3e\$68t\$1@newscl01ah.mathworks.com> <iq9rjp\$g0n\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1304983925 20796 172.30.248.46 (9 May 2011 23:32:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 May 2011 23:32:05 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:725950

"Roger Stafford" wrote in message <iq9rjp\$g0n\$1@newscl01ah.mathworks.com>...
> .......
>  t1 = [x,false]; t2 = [false,x];
>  f1 = find(t1==1 & t2~=1); f2 = find(t1~=1 & t2==1);
>  y = zeros(size(x));
>  y(f2-1) = f2-f1;
>
> Roger Stafford
- - - - - - - - -
Assuming x really is a logical type I should have written:

t1 = [x,false]; t2 = [false,x];
f1 = find(t1&~t2); f2 = find(~t1&t2);
y = zeros(size(x));
y(f2-1) = f2-f1;

Roger Stafford
```