How do I determine the distance between ALOT of points smoothly?
古いコメントを表示
So, I have an array consisting of about 82000 x and y coordinates. I want to find out how many "neighbours" each points has within a radius of some value. I wrote something that does this, however the code takes roughly two months to compile...
I've been doing it with two for-loops (not a good idea), one running alle the points one by one and another checking the distance from the one point to each of the 82000 others. This does not work in practice.
Any good suggestions?
採用された回答
その他の回答 (2 件)
Image Analyst
2014 年 5 月 5 日
Try eliminating the square root in the distance calculation and finding how how many points distance squareds are within the radius squared (calculated before the loop):
radius2 = radius^2
for k = 1 : length(x)
....
distance2 = deltax^2 + deltay^2;
if distance2 <= radius2
count = count + 1
カテゴリ
ヘルプ センター および File Exchange で Image display and manipulation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!