From help-request at octave dot org Wed May 5 02:10:22 2004 Subject: Re: sort question From: geordie dot mcbain at aeromech dot usyd dot edu dot au To: "Michael Underwood" , Date: Wed, 5 May 2004 17:05:09 +1000 Easy: ask two return values of sort (): octave> [b, ib] = sort (a) The second holds the desired indices. On Wed, 5 May 2004 04:56 pm, Michael Underwood wrote: > I looking for a neat way of determining the index that of each element of > an array would have if sorted. > > eg. > octave:1> a = rand(4,1) > a = > > 0.73433 > 0.55564 > 0.49191 > 0.90766 > > octave:2> b= sort(a) > b = > > 0.49191 > 0.55564 > 0.73433 > 0.90766 > > for instance, a(1) is the 3rd element of b. > > I know this can be done with the find command, but the array I am dealing > with are sufficiently large to make the find command too time consuming. > > Any ideas?? > > > Regards > > Michael Underwood > > Systems Analyst > Generation Division > Hydro Tasmania > > Ph: (03) 6230 5494 > > This message and any attachments may contain confidential or privileged > information, and are intended solely for the named recipient(s). If you are > not a named recipient of this message, you are hereby notified that you > must not use, disseminate, copy or take any action in reliance on this > message or any part of it. If you have received this message in error, > please notify the author immediately via > mailto:michael dot underwood at hydro dot com dot au > > NB: Unless otherwise specified, opinions and personal views expressed > herein are purely those of the author and do not represent the views of > Hydro Tasmania. ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------