Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how do you find adjacent numbers fast?
Date: Wed, 23 Jun 2010 19:52:21 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 28
Message-ID: <hvtolk$5lq$1@fred.mathworks.com>
References: <57dc7fe3-2b8b-4ed7-870c-b73c87ae24d4@a3g2000vbl.googlegroups.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277322741 5818 172.30.248.38 (23 Jun 2010 19:52:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jun 2010 19:52:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:647535

Luna Moon <lunamoonmoon@gmail.com> wrote in message <57dc7fe3-2b8b-4ed7-870c-b73c87ae24d4@a3g2000vbl.googlegroups.com>...
> Here is the number I want to find, let's call it x,
> 
> here is the big vector, let me call it A,
> 
> I want to find the number x in A, in a fuzzy way.
> 
> Lets do an example: x=3, A=[0, 1, 2, 3, 4, 5],
> then I want to identify the target location to be position 4.
> 
> Another example:
> x=3, A=[0, 2, 4, 6, 8],
> then I want to identify the target locations to be positions 2 and 3,
> (i.e. the immediate location right before the placehold that x should
> be in, and one immediately after...)
> i.e. x=3 should have been in between 2 and 3, since we couldn't find
> it in the vector
> 
> A is an ordered vector... not a set...
> 
> How to do that?

You won't believe me. People never do on this matter.
But the second return argument from histc does exactly
this.

HTH,
John