Knnsearch: How to output disntace?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Pelajar UM
el 26 de Oct. de 2021
Editada: Pelajar UM
el 26 de Oct. de 2021
Here's the code. It basically finds the nearest sets of x,y,z points in the nodes array. Since the first column is the point itself, K=2, so that it finds the second nearest point. Then it generates a new array Near which sorts the data based on this new index.
Idx=knnsearch (nodes,nodes,'K',2)
Idx2=Idx(:,2)
Near=nodes(Idx2,:)
According to the documentation, there's an output argument D that should give the distance. But how do I implement it?
0 comentarios
Respuesta aceptada
Esen Ozbay
el 26 de Oct. de 2021
If you write
[Idx, dist] =knnsearch (nodes,nodes,'K',2);
you will obtain the distances mentioned in the documentation.
1 comentario
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!