Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help with code to shift and catch 0's and 1's
Date: Wed, 27 Apr 2011 13:49:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 12
Message-ID: <ip96sh$7pp$1@fred.mathworks.com>
References: <ip8k2k$lc$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1303912145 7993 172.30.248.46 (27 Apr 2011 13:49:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 27 Apr 2011 13:49:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:724104

"Jason " <core_ab56@hotmail.com> wrote in message <ip8k2k$lc$1@fred.mathworks.com>...
> .......
> 00100010000
> I need help with a code that can re-arrange to look like this:
> 00011110000
> .......
- - - - - - - - -
  If x is your original column vector of 1's and 0's (and if I have generalized your example correctly,) do this:

 y = mod(cumsum([0;x(1:end-1)]),2);

Roger Stafford