Skip to Main Content Skip to Search
Product Documentation

dsearchn - N-D nearest point search

Syntax

k = dsearchn(X,T,XI)
k = dsearchn(X,T,XI,outval)
k = dsearchn(X,XI)
[k,d] = dsearchn(X,...)

Description

k = dsearchn(X,T,XI) returns the indices k of the closest points in X for each point in XI. X is an m-by-n matrix representing m points in n-dimensional space. XI is a p-by-n matrix, representing p points in n-dimensional space. T is a numt-by-n+1 matrix, a triangulation of the data X generated by delaunayn. The output k is a column vector of length p.

k = dsearchn(X,T,XI,outval) returns the indices k of the closest points in X for each point in XI, unless a point is outside the convex hull. If XI(J,:) is outside the convex hull, then K(J) is assigned outval, a scalar double. Inf is often used for outval. If outval is [], then k is the same as in the case k = dsearchn(X,T,XI).

k = dsearchn(X,XI) performs the search without using a triangulation. With large X and small XI, this approach is faster and uses much less memory.

[k,d] = dsearchn(X,...) also returns the distances d to the closest points. d is a column vector of length p.

Algorithms

dsearchn is based on Qhull [1]. For information about Qhull, see http://www.qhull.org/. For copyright information, see http://www.qhull.org/COPYING.txt.

References

[1] Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Transactions on Mathematical Software, Vol. 22, No. 4, Dec. 1996, p. 469–483.

See Also

DelaunayTri | dsearch

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS