From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find nearest,closest value
Date: Sun, 1 May 2011 01:51:05 +0000 (UTC)
Organization: Queen's University
Lines: 21
Message-ID: <ipiea9$3vr$>
References: <gmf901$45e$> <gnaitl$5dn$> <i8o734$a2d$> <i8ofdc$ove$> <i8p8t2$p4c$> <i8q3g8$o52$> <i8qds3$ana$> <i8qhm1$cfp$> <i8s0rb$la7$> <i8s483$i4a$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1304214665 4091 (1 May 2011 01:51:05 GMT)
NNTP-Posting-Date: Sun, 1 May 2011 01:51:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2643899
Xref: comp.soft-sys.matlab:724629

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <i8s483$i4a$>...
> Sorry: The criteria I stated earlier is flawed, that means the closest L1 point can be even not connected to closest L2 point by any Delaunay simplex.
> Bruno

This is an interesting problem, similar to my present problem:
 Back to the original problem, yet, I do not only attempt to find the closest value from a to b, but also attempt to replace the closest value in a to that in b, and return the index of being replaced elements in a. Notice that if two elements in b corresponds to the same element in a as the common nearest value, then I may want to replace that value in a with the closest or most lefthandside nearest points in b.

For example, 
a=[1, 2, 3, 4, 5, 6];
b=[2.1, 1.9, 3.2];
 Obviously, both 1.9 and 2.2 in b close to 2 in a, but I want to replace 2 with 1.9 as ,1.9 is the nearest point in the leftside of 2. Such that, I attempt to obtain the following new vector and index of elements being replaced:
new_a=[1, 1.9, 3.2, 4, 5, 6];
index_replaced_in_a=[2, 2, 3];

Could you guys figure out a way to do so in a general way? a,b can be vectors or arrays of coordinates set (not so important)...

Thank you very much!