NeighborSearcher class

Nearest neighbor search object


NeighborSearcher is an abstract class used for nearest neighbor search. You cannot create instances of this class directly. Instead, create an instance of a derived class such as ExhaustiveSearcher or KDTreeSearcher either by calling the derived class constructor or by calling the function createns.


NeighborSearcher is an abstract class. You cannot create instances of this class directly. You can construct an object in a subclass, such as KDTreeSearcher or ExhaustiveSearcher, either by calling the subclass constructors or by using the createns function.



A matrix used to create the object.


A string specifying a built-in distance metric (applies to both ExhaustiveSearcher and KDTreeSearcher) or a function handle (only applies to ExhaustiveSearcher) that you provide when you create the object. This property is the default distance metric used when you call the knnsearch method to find nearest neighbors for future query points.


Specifies the additional parameter for the chosen distance metric. The value is:

  • If 'Distance' is 'minkowski': A positive scalar indicating the exponent of the Minkowski distance. (Applies for both ExhaustiveSearcher and KDTreeSearcher.)

  • If 'Distance' is 'mahalanobis': A positive definite matrix representing the covariance matrix used for computing the Mahalanobis distance. (Only applies for ExhaustiveSearcher.)

  • If 'Distance' is 'seuclidean': A vector representing the scale value of the data when computing the 'seuclidean' distance. (Only applies for ExhaustiveSearcher.)

  • Otherwise: Empty.

Was this topic helpful?