How to find k nearest vectors from a given vector in 3 dimensions ?
Afficher commentaires plus anciens
I have a reference vector and I want to find a fixed k nearest neighbors from a matrix ? How can I do it? Is there any direct way?
1 commentaire
Walter Roberson
le 16 Mai 2015
When you say "reference vector", do you mean a line defined in N-dimensional space? And you want to find the k points that lie nearest to the line using Euclidean distance? Or does "reference vector" just mean an N-dimensional point and you want to find its k nearest neighbours using a distance measure you have not specified, possibly Euclidean distance?
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 16 Mai 2015
Let Q1 and Q2 be any two distinct points of the line and P the point in question, then
d = norm(cross(Q2-Q1,P-Q1))/norm(Q2-Q1);
will give the requested orthogonal distance.
Catégories
En savoir plus sur Nearest Neighbors dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!