Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how do you find adjacent numbers fast?
Date: Wed, 23 Jun 2010 19:57:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <hvtoug$nc3$1@fred.mathworks.com>
References: <57dc7fe3-2b8b-4ed7-870c-b73c87ae24d4@a3g2000vbl.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277323024 23939 172.30.248.37 (23 Jun 2010 19:57:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jun 2010 19:57:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:647538

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?
> 
> thanks

 [ignore,bin] = histc(x,A);

Roger Stafford