idx = knnsearch(X, Y)
idx = knnsearch(X, Y, Name, Value)
[idx, D] = knnsearch(...)
knnsearch finds nearest rows of X for each query row of Y using an exhaustive native search.
Supported options include K, Distance, IncludeTies, NSMethod, SortIndices, P, Scale, Cov, BucketSize, and CacheSize. When IncludeTies is true, outputs are cell arrays.
X = [0 0; 1 0; 0 2; 4 4];
Y = [0 1; 3 4];
[idx, D] = knnsearch(X, Y, 'K', 2)
| Version | Description |
|---|---|
| 2.0.0 | initial version |