Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Getting Top 'k' most negative value indices in matrix
Date: Tue, 6 Jul 2010 17:19:07 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 19
Message-ID: <i0voib$1do$1@fred.mathworks.com>
References: <i0vn5o$sqt$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1278436747 1464 172.30.248.37 (6 Jul 2010 17:19:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 6 Jul 2010 17:19:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1597503
Xref: news.mathworks.com comp.soft-sys.matlab:650816

"Rahul Singhal" <rsinghalomatic@gmail.com> wrote in message <i0vn5o$sqt$1@fred.mathworks.com>...
> Hi All,
>   I have a matrix which contains some negative values. I want to get the indices of top 'k' most negative values in matrix. 
> 
> How can i do that?
> 
> Thanks and Regards
> Rahul

Hi Rahul, have you read the documentation for sort?

reset(RandStream.getDefaultStream);
A = randn(10,10);
[B,I] = sort(A(:));
A(I(1:10))  %smallest ten elements  I(1:10) are the indices

Is this what you're getting at?

Wayne