Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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

Advanced Search

Back to Topic List Back to Topic List  
Bruce Bowler

Posts: 236
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;
end

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?

TIA,
Bruce



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.