Find close points in two matrices of coordinates

1 view (last 30 days)
I have two different length matrices of 3D coordinates. I want to find all the unique coordinates in one matrix that are within a certain Euclidean distance of any of the coordinates in the other matrix. What is the most efficient way to do this?

Accepted Answer

Torsten on 22 Sep 2022
Edited: Torsten on 22 Sep 2022
Use "pdist2" to calculate the distances of the sites of the first set to the sites of the second set.
Check which rows of the distance matrix D have an entry <= dmax where dmax is your prescribed maximum distance.
These are the sites of the first set you want to determine.
Adam Fitchett
Adam Fitchett on 28 Sep 2022
This worked thanks, although it turned out to be very memory-hungry for my large matrices
Used 98% of the RAM on a workstation with 256 GB of RAM!

Sign in to comment.

More Answers (0)





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!