Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!l33g2000pri.googlegroups.com!not-for-mail
From: fas <faisalmufti@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Sort and revert
Date: Sat, 15 Nov 2008 17:39:24 -0800 (PST)
Organization: http://groups.google.com
Lines: 40
Message-ID: <7d82d1f5-2af6-42b8-abe1-f9d2707387c4@l33g2000pri.googlegroups.com>
References: <195e56e8-c7b9-49b3-839f-fd0468067e86@35g2000pry.googlegroups.com> 
	<gfgjl1$r0c$1@fred.mathworks.com> <gfh98n$o8e$1@fred.mathworks.com>
NNTP-Posting-Host: 150.203.45.195
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1226799564 8620 127.0.0.1 (16 Nov 2008 01:39:24 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 16 Nov 2008 01:39:24 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l33g2000pri.googlegroups.com; posting-host=150.203.45.195; 
	posting-account=GPH0AgoAAAAxfbd_rNaAdoRNt4LD8YmY
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.0.4) 
	Gecko/2008102920 Firefox/3.0.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:501033


On Nov 14, 12:15=A0am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Roger Stafford" <ellieandrogerxy...@mindspring.com.invalid> wrote in mes=
sage <gfgjl1$r0...@fred.mathworks.com>...
> > fas <faisalmu...@gmail.com> wrote in message <195e56e8-c7b9-49b3-839f-f=
d0468067...@35g2000pry.googlegroups.com>...
> > > Hi,
> > > I have a vector which I have sorted B=3Dsort(A); Now after changing t=
he
> > > 10 values on either end I would like to take the vector back to A.
> > > B=3Dsort(A);
> > > B(1:10)=3D20;
> > > B(90:100)=3D70;
> > > 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 ?
>
> > =A0 Use the second output argument of 'sort':
>
> > =A0[B,p] =3D sort(A);
> > =A0B(1:10) =3D 20;
> > =A0B(90:100) =3D 70;
> > =A0A(p) =3D B;
>
> > Roger Stafford
>
> =A0 Or you could do this instead:
>
> =A0[p,p] =3D sort(A);
> =A0A(p(1:10)) =3D 20;
> =A0A(p(90:100)) =3D 70;
>
> Roger Stafford

Thanks a lot Roger!