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

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gfgjl1$r0c$1@fred.mathworks.com>...
> 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

  Or you could do this instead:

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

Roger Stafford