Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe03.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: Split a monotonic array
References: <gdg54q$3e1$1@fred.mathworks.com>
In-Reply-To: <gdg54q$3e1$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <T6OKk.2593$JT3.2410@newsfe03.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe03.iad 1224453683 24.79.146.116 (Sun, 19 Oct 2008 22:01:23 UTC)
NNTP-Posting-Date: Sun, 19 Oct 2008 22:01:23 UTC
Date: Sun, 19 Oct 2008 17:01:35 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:496108


Bruno Luong wrote:
> I have a strict sorted array such as
> A = [ 8 17 24 29 33 36 39 45 56 64 ]
> I would like to split this array into non-overlapping parts such that: in each
> part A is bracketed in a interval not larger than a given length said dmax=30.
> So in the above I would have
> A1 = [ 8 17 24 ]
> A2 = [ 29 29 33 36 39 45 ]
> A3 = [ 56 64 ]

idx = cumsum([1, diff(A) > dmax]);

Then A(K) goes in to B{idx(K)}
(though I haven't given the loop to make that happen ;-) )