Path: news.mathworks.com!not-for-mail
From: "Martin " <oneaccount@hotmail.co.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Sorting a vector string
Date: Wed, 17 Feb 2010 19:13:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <hlhf4g$19g$1@fred.mathworks.com>
Reply-To: "Martin " <oneaccount@hotmail.co.uk>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1266434000 1328 172.30.248.35 (17 Feb 2010 19:13:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 17 Feb 2010 19:13:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1702014
Xref: news.mathworks.com comp.soft-sys.matlab:608959

I would appreciate any help with this:

I enter the following code:

a=[10 30 80 70 40 90 60 20 80]
[aa,bb]=sort(a)
cc=[1:1:9]
dd=[cc-bb]

asking for dd gives me the string

0 -6 1 -1 -4 -1 3 5 3

How do I ask matlab to now put the postion moves under the respective numbers in string a? So it displays as:

0 1 5 3 -1 3 -1 -6 -4

Such that the number of moves made by the number to put it in orde are placed in the position of the respective number in string a, rather than in the prosition of its number once arranged in order.

I hope this makes sense? Any help very much appreciated. 

thank you