Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!news2.glorb.com!news.cse.ohio-state.edu!pitt.edu!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Indices of vectors
Date: Mon, 29 Nov 2010 17:49:39 -0600
Organization: Canada Eat The Cookie Foundation
Lines: 19
Message-ID: <id1e6o$8ud$1@canopus.cc.umanitoba.ca>
References: <id1d9d$sqq$1@fred.mathworks.com>
NNTP-Posting-Host: ibd-nat.ibd.nrc.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: canopus.cc.umanitoba.ca 1291074584 9165 132.246.133.10 (29 Nov 2010 23:49:44 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Mon, 29 Nov 2010 23:49:44 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10
In-Reply-To: <id1d9d$sqq$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:691034

On 10-11-29 05:34 PM, David Neibig wrote:
> Just wondering whether the following is possible: I have vector of values:

> A=[ 2 4 6 8 10]
> B= find(a)
> C=sort(a,'descend')

> B generates the vector 1 2 3 4 5 and C generates 10 8 6 4 2

> Is there anyway in which the index of a specific number can be
> translated between the vectors A and C, and whether this is possible for
> all values of A, even when a has an arbitrary length

No. You would not be able to handle duplicate values that way.

However, what you want to do is very easy solved: use the two-output version 
of sort.

[C,D] = sort(a,'descend')