Create object to use in knearest neighbors search
NS = createns(X)
NS = createns(X,'Name
',Value
)
NS = createns(X)
uses the data observations
in an mxbyn matrix X
to
create an object NS
. Rows of X
correspond
to observations and columns correspond to variables. NS
is
either an ExhaustiveSearcher
or
a KDTreeSearcher
model
object which you can use to find nearest neighbors in X
for
desired query points. If NS
is an ExhaustiveSearcher
model, knnsearch
and rangesearch
use
the exhaustive search algorithm to find nearest neighbors. If NS
is
a KDTreeSearcher
model, createns
grows
and saves a Kdtree based on X
in NS
. knnsearch
and rangesearch
use
the Kdtree to find nearest neighbors. For information
on these search methods, see kNearest Neighbor Search and Radius Search.
NS = createns(X,'
accepts
one or more optional name/value pairs. Specify Name
',Value
)Name
inside
single quotes. Specify NSMethod
to determine which
type of object to create. The object's properties save the information
when you specify other arguments. For more information on the objects'
properties, see ExhaustiveSearcher or
a KDTreeSearcher.

Nearest neighbors search method, used to define the type of object created. Value is either:


A character vector or a function handle specifying the default
distance metric used when you call For both
The following options apply to


A positive scalar, p, indicating the exponent
of the Minkowski distance. This parameter is only valid when 

A positive definite matrix indicating the covariance matrix
when computing the Mahalanobis distance. This parameter is only valid
when 

A vector 

A positive integer, indicating the maximum number of data points in each leaf node of the Kdtree. This argument is only meaningful when using the Kdtree search method. Default is 50. 
ExhaustiveSearcher
 KDTreeSearcher
 knnsearch
 rangesearch