Path: news.mathworks.com!not-for-mail
From: "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Picking Ones among Zeros
Date: Mon, 6 Jul 2009 08:29:02 +0000 (UTC)
Organization: Ricardo UK Ltd
Lines: 11
Message-ID: <h2scke$djp$1@fred.mathworks.com>
References: <h2oif2$g5h$1@fred.mathworks.com> <h2okru$frv$1@fred.mathworks.com>
Reply-To: "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246868942 13945 172.30.248.38 (6 Jul 2009 08:29:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Jul 2009 08:29:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 43398
Xref: news.mathworks.com comp.soft-sys.matlab:552992


"Matt Fig" <spamanon@yahoo.com> wrote in message <h2okru$frv$1@fred.mathworks.com>...
> If you don't have bwlabel, this should work:
> 
> D = diff(findstr(a,1));
> diff([0 find(D~=1) length(D)+1])
> 
> caveat: I didn't test this out on MATLAB, this PC doesn't have it.  I think this will work though!

Nit-pic...

~D is generally a lot faster than D~=1.  By a factor of about 10-15 on my PC.