Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Computing euclidean distances between every row of a position matrix
Date: Wed, 1 Jun 2011 20:21:04 +0000 (UTC)
Organization: Princeton University
Lines: 6
Message-ID: <is66vg$ruv$1@newscl01ah.mathworks.com>
References: <is3lku$ku1$1@newscl01ah.mathworks.com> <is3rco$5vj$1@newscl01ah.mathworks.com> <is5g9t$gs9$1@newscl01ah.mathworks.com> <is613u$9a6$1@newscl01ah.mathworks.com> <is6658$pbh$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306959664 28639 172.30.248.45 (1 Jun 2011 20:21:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Jun 2011 20:21:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2886263
Xref: news.mathworks.com comp.soft-sys.matlab:729752

"Image Analyst" wrote in message <is6658$pbh$1@newscl01ah.mathworks.com>...
> How about
> minDistances = min(distanceMatrix(distanceMatrix>0), [], 2);
> That way, you're only computing the minimum of values that are greater than zero.  The elements having values that are zero (or less) are ignored.

Thanks very much for the suggestion. I actually just realized that I can use the sort function to sort the distance matrix and then it's really easy to get any number of minimum values, and there indices are a piece of cake! Maybe that realization will help someone else in the future- seriously, way easier than dealing with the min function.