From: Jos <x@y.z>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find beginning of epoches
Message-ID: <ef5cd86.4@webcrossing.raydaftYaTP>
Date: Mon, 9 Jul 2007 07:28:00 -0400
References: <ef5cd86.-1@webcrossing.raydaftYaTP> <ef5cd86.3@webcrossing.raydaftYaTP>
Lines: 26
NNTP-Posting-Host: 156.83.1.251
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:417982



us wrote:
>
>
> kai voges:
> <SNIP looking for an event's time...
>
> one of the solutions
>
> a=0:10:40;
> b=31;
> [ix,ix]=min(abs(a-b));
> % the result
> [ix;a(ix);b]
>
> us

Another approach for multiple events:

  a=0:10:40;
  b= [31 ; 22 ; 5 ] ;
  [ix,ix] = histc(b,a) ;
% the result
  [ix(:) a(ix).' b(:)]

hth
Jos