Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: sort and positon matrix element help

  • To: mathgroup at
  • Subject: [mg73077] Re: [mg73050] sort and positon matrix element help
  • From: Sseziwa Mukasa <mukasa at>
  • Date: Thu, 1 Feb 2007 03:39:22 -0500 (EST)
  • References: <>

On Jan 31, 2007, at 12:12 AM, comp.soft-sys.math.mathematica wrote:

> Hi, guys,
>         I am attacking one proble and may need your help.
>         I have a large matrix(m*n). I wanna to sort out the matrix
> from large to small according to its element's value AND save the
> corresponding row and column number as its position. Latter on, plot
> out the first 20 largest value accroding to their positions.
>         Is there any good way to do this, especially take out the
> positons of element and assocate it with the value?

You can get the largest 20 elements of the array with Ordering[Flatten 

Position[array,Union[Ordering[Flatten[array],-20]] will get you the  
positions of those elements including possible duplicates.

If your array is large but you only care about 20 elements, you can  
cut down your storage requirements by not storing the sorted array or  
appending position information for all the elements.



  • Prev by Date: Re: Remote Kernel does nothing
  • Next by Date: Re: Re: How to do quickest
  • Previous by thread: Re: sort and positon matrix element help
  • Next by thread: Re: sort and positon matrix element help