How do I allocate one point only in matrix A to its closest point in matrix B
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone!
relatively new to MATLAB and would like some help.
I have 2 2D points arrays A, B. I need to connect each point in matrix A to its closest point in matrix B.
The issue is that I can connect just 1 point from A to just 1 point in B. So if a point in A is further away from all the points in B then all other points in A I need to discard it.
This complicates things because it becomes recursive.. and I'm not sure how to implicate this.
If anyone has an idea or advice it will be awesome!
Thanks!
0 Kommentare
Antworten (1)
KSSV
am 24 Okt. 2020
Bearbeitet: KSSV
am 24 Okt. 2020
Read about knnsearch. This function will give you the number points you specified which are close.
idx = knnsearch(B,A) ;
B(idx,:) % these are the points in B close to A
2 Kommentare
KSSV
am 24 Okt. 2020
You need not to bother about that....you specify that you need one point in knnsearch, it will give the closest point.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!