The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Finding the minumum distance for LOTS of points
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Bruce Bowler

Posts: 303
Registered: 12/7/04
Finding the minumum distance for LOTS of points
Posted: Apr 8, 2013 11:44 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have a 80,000+ element vector which are indices into 2 512x640 arrays
(one is latitude, the other longitude, let's call them alat and alon).

I have 2 other arrays that are 666x730. They are also latitude and
longitude (lets call these blat and blon). There's a 3rd 666x730 array
called data.

For each of the positions indicated in alat and alon, I want to find the
closest position in blat and blon and set the corresponding element in
data to nan.

What I have so far is...

for ix = 1:numel(nans)
dist = distance(alat(nans(ix)),alon(nans(ix)),blat,blon);
[~,closest] = min(min(dist));
data(closest) = nan;

It appears to be working, but molasses in winter doesn't even begin to
describe the speed.

Is there a better way to approach this?


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.