Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to generate the runs in a vector fast?
Date: Wed, 16 Jun 2010 14:33:04 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 18
Message-ID: <hvanb0$r5t$1@fred.mathworks.com>
References: <75f39778-f788-46b7-8927-1f381338e9d1@f16g2000vbl.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1276698784 27837 172.30.248.37 (16 Jun 2010 14:33:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jun 2010 14:33:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:645386

Lucy <comtech.usa@gmail.com> wrote in message <75f39778-f788-46b7-8927-1f381338e9d1@f16g2000vbl.googlegroups.com>...
> Hi all,
> 
> I hvae a vector of 1, 0, -1s. I want to find the histogram of the
> number of consecutive numbers, ie the histogram of the runs.
> 
> For example, how many two 1s, three 1s, four 1s in a row, and those of
> -1s, etc.
> 
> How to do this fast? Hopefully without for loops?
> 
> Thx a lot

this little FEX utility may be helpful

http://www.mathworks.com/matlabcentral/fileexchange/6436

us