Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Sort and revert
Date: Thu, 13 Nov 2008 07:06:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 24
Message-ID: <gfgjl1$r0c$1@fred.mathworks.com>
References: <195e56e8-c7b9-49b3-839f-fd0468067e86@35g2000pry.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226559969 27660 172.30.248.35 (13 Nov 2008 07:06:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Nov 2008 07:06:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:500567

fas <faisalmufti@gmail.com> wrote in message <195e56e8-c7b9-49b3-839f-fd0468067e86@35g2000pry.googlegroups.com>...
> Hi,
> I have a vector which I have sorted B=sort(A); Now after changing the
> 10 values on either end I would like to take the vector back to A.
> B=sort(A);
> B(1:10)=20;
> B(90:100)=70;
> Now I want to transform B->A so that the indexing is same of what my A
> was.
> 
> Since its an image I have to revert back to same indexing of vector
> only with changed values that I did after sorting.
> 
> Any idea ?

  Use the second output argument of 'sort':

 [B,p] = sort(A);
 B(1:10) = 20;
 B(90:100) = 70;
 A(p) = B;

Roger Stafford