From: Rahul Singhal on 6 Jul 2010 12:55 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
From: dpb on 6 Jul 2010 13:08 Rahul Singhal wrote: > 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? .... Would that not be the k smallest entries? If so, the brain-dead way would be xsort = sort(x(:)); min_k = xsort(1:k); --
From: Roger Stafford on 6 Jul 2010 13:13 "Rahul Singhal" <rsinghalomatic(a)gmail.com> wrote in message <i0vn5o$sqt$1(a)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 - - - - - - - - - Check out this FEX contribution by Bruno Luong: http://www.mathworks.com/matlabcentral/fileexchange/23576-minmax-selection Roger Stafford
From: Oleg Komarov on 6 Jul 2010 13:13 "Rahul Singhal" <rsinghalomatic(a)gmail.com> wrote in message <i0vn5o$sqt$1(a)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 k = 9; A = rand(10,10); [sortedA, idx] = sort(A(:)); kMostNeg = idx(end-k:end); Oleg
From: Oleg Komarov on 6 Jul 2010 13:14
typo, last line should be: kMostNeg = idx(end-k+1:end); Oleg |