This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


N-D closest simplex search


t = tsearchn(X,TRI,XI)
[t,P] = tsearchn(X,TRI,XI)


t = tsearchn(X,TRI,XI) returns the indices t of the enclosing simplex of the Delaunay triangulation TRI 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. tsearchn returns NaN for all points outside the convex hull of X. If a point in XI lies on the boundary of two or more simplexes, then the largest index is returned. tsearchn requires a triangulation TRI of the points X obtained from delaunayn.

[t,P] = tsearchn(X,TRI,XI) also returns the barycentric coordinate P of XI in the simplex TRI. P is a p-by-n+1 matrix. Each row of P is the barycentric coordinate of the corresponding point in XI. It is useful for interpolation.


  • The pointLocation function can provide better search performance for some 2-D and 3-D triangulations, such as finite element meshes.

Introduced before R2006a