Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Array manipulation question
Date: Tue, 21 Aug 2007 18:50:10 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 17
Message-ID: <fafc52$lj9$1@canopus.cc.umanitoba.ca>
References: <fafah8$ot$1@fred.mathworks.com> <fafbev$dku$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1187722210 22121 192.70.172.160 (21 Aug 2007 18:50:10 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 21 Aug 2007 18:50:10 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:424828



In article <fafbev$dku$1@fred.mathworks.com>, us  <us@neurol.unizh.ch> wrote:
>Adam:
><SNIP error of <sort>s...

>> I can't use the sort function because it re-orders the 
>array and I would lose the index information...

>     v=[3,4,1,2,5].';
>     [vs,vx]=sort(v);
>     n=3;
>     r=[vs(1:n),vx(1:n)];

That will give the values in sorted order, but Adam wants the values
in the original order (for whatever reason). See my posting for
the (small) change needed to get the original order.
-- 
   Okay, buzzwords only. Two syllables, tops.  -- Laurie Anderson