Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe06.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: Reversing a row matrix
References: <gcnqe3$s7h$1@fred.mathworks.com>
In-Reply-To: <gcnqe3$s7h$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 15
Message-ID: <WeKHk.8547$JJ4.7906@newsfe06.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe06.iad 1223651382 24.79.146.116 (Fri, 10 Oct 2008 15:09:42 UTC)
NNTP-Posting-Date: Fri, 10 Oct 2008 15:09:42 UTC
Date: Fri, 10 Oct 2008 10:10:14 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:494572


Emeka Obe wrote:

> I need to reverse a matrix as follows:
> If x=[1 3 8 20 100 121], 

> how do I get a matrix 

> y=[121 100 20 8 3 1]

> An answer is needed, please.

r = randperm(length(x));
t1 = x(r);
[t2,t3] = sort(r,'descend');
y = t1(t3);