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$>
References: <i0vn5o$sqt$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1278436747 1464 (6 Jul 2010 17:19:07 GMT)
NNTP-Posting-Date: Tue, 6 Jul 2010 17:19:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1597503
Xref: comp.soft-sys.matlab:650816

"Rahul Singhal" <> wrote in message <i0vn5o$sqt$>...
> 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?

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?