Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sorting, ranking
Date: Fri, 21 Aug 2009 15:53:53 -0400
Organization: The MathWorks, Inc.
Lines: 43
Message-ID: <h6mu08$aua$1@fred.mathworks.com>
References: <h6mh83$j42$1@fred.mathworks.com> <h6mjir$ji9$1@fred.mathworks.com> <h6moqe$sqf$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1250884424 11210 172.31.44.65 (21 Aug 2009 19:53:44 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 21 Aug 2009 19:53:44 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:565157


"Wyatt " <hello@hello.com> wrote in message 
news:h6moqe$sqf$1@fred.mathworks.com...
> that did the trick steve.  It just seems to me that
>
> rank = temp(I)
>
> should be valid syntax,

It is.  It just doesn't do what you expect it to do.

> and is more intuitive than writing
>
> rank(I) = temp

Why do you say that?  "rank = temp(I)" is a valid MATLAB command in this 
scenario, but so is "rank = I.^2" or "rank = sin(cos(tan(I)))".  Each of 
those commands do something different; for the application you described in 
your original post, the command that does what you want is "rank(I) = temp".

Although you probably shouldn't use rank as a variable name, unless you're 
okay with not being able to use the RANK function in the same piece of code.

> perhaps because I'm thinking that if I wanted to arbitrarily pull out 
> values [7 4 9 1] from a vector A I would write
>
> A([7 4 9 1])
>
> and it would give me the 7th 4th 9th and 1st values from A in that order.

Yes.  And if you wanted to store 1:4 into the 7th, 4th, 9th, and 1st 
elements of A, you'd use:

A([7 4 9 1]) = (1:4);

Just because one command works does not necessarily rule out a modification 
of that command also working and doing something slightly different.

-- 
Steve Lord
slord@mathworks.com