Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simplify an array
Date: Wed, 21 Nov 2007 10:11:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <fi107t$82k$1@fred.mathworks.com>
References: <fi0prq$r33$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1195639869 8276 172.30.248.37 (21 Nov 2007 10:11:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 21 Nov 2007 10:11:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:438650


"Uwe Gallaun" <uwe.gallaun@stud.unileoben.ac.at> wrote in message 
<fi0prq$r33$1@fred.mathworks.com>...
> dear matlab users
> 
> array=
> [1] [2]
> [3] [4]
> [5] [7]
> [6] [7]
> [7] [8]
> [9] [10]
> [10][11]
> now i'm trying to look if the numbers in the first column
> growing with increment 1. 
> as result i want to display this array:
> result=
> [1] [2]
> [3] [4]
> [5] [8]
> [9] [11]
> 
> for example: 
> three points 
> [5] [7]
> [6] [7]
> [7] [8]
> i'm trying to simplify it to get the start and the end:
> [5] [8]
> 
> how can i get this result-array?
> 
> thanx
-------
  Is this what you want?  Call 'a' be the original two-columned array.

 d = diff(a(:,1))~=1;
 r = [a([true;d],1),a([d;true],2)]; % The result

Roger Stafford