Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

nearestNeighbor - Class: DelaunayTri

Point closest to specified location

Syntax

PI = nearestNeighbor(DT, QX)
PI = nearestNeighbor(DT, QX,QY)
PI = nearestNeighbor(DT, QX,QY,QZ)

Description

PI = nearestNeighbor(DT, QX) returns the index of nearest point in DT.X for each query point location in QX.

PI = nearestNeighbor(DT, QX,QY) and PI = nearestNeighbor(DT, QX,QY,QZ) allow the query points to be specified in alternative column vector format when working in 2-D and 3-D.

Inputs

DTDelaunay triangulation.
QXThe matrix QX is of size mpts-by-ndim, mpts being the number of query points and ndim the dimension of the space where the points reside.

Outputs

PIPI is a column vector of point indices that index into the points DT.X. The length of PI is equal to the number of query points mpts.

Examples

Create a Delaunay triangulation:

x = rand(10,1);
y = rand(10,1);
dt = DelaunayTri(x,y);

Create query points:

qrypts = [0.25 0.25; 0.5 0.5];

Find the nearest neighbors to the query points:

pid = nearestNeighbor(dt, qrypts)

See Also

DelaunayTri.pointLocation

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS