Path: news.mathworks.com!not-for-mail
From: "David Doria" <daviddoria@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Top N values in a multidimensional array
Date: Tue, 28 Oct 2008 19:43:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <ge7q06$4k2$1@fred.mathworks.com>
Reply-To: "David Doria" <daviddoria@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225222982 4738 172.30.248.38 (28 Oct 2008 19:43:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 28 Oct 2008 19:43:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1105197
Xref: news.mathworks.com comp.soft-sys.matlab:497690


I didn't see anything like on the file exchange, which really surprised me. 

I have a multidimensional array that I would like to query for the largest N values.  ie if i say

[v loc] = max(A, 2);

where A is 3x3x10, I would like v to be length 2 containing the largest two values, and loc to be length 2 containing the positions of those values (a coordinate in the nXmXp space).

Does someone know of a script like this that I just missed on the file exchange? It just seems like it would be terribly inefficient if I wrote it.

Thanks,

Dave