ID = nearestNeighbor(TR,P)
returns the IDs of the vertices closest to the query points in P.
Each row in the matrix P contains the coordinates of a query
point.
Triangulation representation, specified as a scalar triangulation or delaunayTriangulation object.
nearestNeighbor does not support
delaunayTriangulation objects with constrained
edges.
Data Types: triangulation | delaunayTriangulation
Query points, specified as a matrix with 2 or 3 columns.
P contains the x-coordinates,
y-coordinates, and (possibly)
z-coordinates of the query points.
Data Types: double
x-coordinates of query points, specified as a column
vector.
Data Types: double
y-coordinates of query points, specified as a column
vector.
Data Types: double
z-coordinates of query points, specified as a column
vector.
Vertex IDs of the nearest neighbors to the query points, returned as a
column vector. A vertex ID is the row number of the corresponding vertex in
the Points property.
Data Types: double
Euclidean distances from the query points to their nearest neighbors,
returned as a column vector the same length as ID.
These syntaxes using DelaunayTri objects as triangulation
representations DT are not recommended:
ID = nearestNeighbor(DT,P) returns the index of the
nearest point in DT.X for each query point location in
matrix P.
Note
nearestNeighbor is not supported
for 2-D triangulations that have constrained edges.
ID = nearestNeighbor(DT,x,y) and ID =
nearestNeighbor(DT,x,y,z) allow the query points to be
specified in column vector format when working in 2-D and 3-D.
[ID,d] = nearestNeighbor(...) returns the corresponding
Euclidean distances between the query points and their nearest neighbors in
D.