Thread Subject: Reversing a row matrix

Subject: Reversing a row matrix

From: Emeka Obe

Date: 10 Oct, 2008 14:56:03

Message: 1 of 5

Hi All,

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.

Emeka

Subject: Reversing a row matrix

From: tpl@eng.cam.ac.uk (Tim Love)

Date: 10 Oct, 2008 15:00:11

Message: 2 of 5

"Emeka Obe" <obeway@gmail.com> writes:

>Hi All,

>I need to reverse a matrix as follows:
fliplr

Subject: Reversing a row matrix

From: Walter Roberson

Date: 10 Oct, 2008 15:10:14

Message: 3 of 5

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);

Subject: Reversing a row matrix

From: Dan Hensley

Date: 10 Oct, 2008 16:24:00

Message: 4 of 5

Emeka Obe wrote:
> Hi All,
>
> 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.
>
> Emeka

y=x(end:-1:1);

Dan

Subject: Reversing a row matrix

From: swgillan

Date: 11 Oct, 2008 06:05:42

Message: 5 of 5

On Oct 10, 7:56=A0am, "Emeka Obe" <obe...@gmail.com> wrote:
> Hi All,
>
> I need to reverse a matrix as follows:
> If x=3D[1 3 8 20 100 121],
>
> how do I get a matrix
>
> y=3D[121 100 20 8 3 1]
>
> An answer is needed, please.
>
> Emeka

>> x=3D[1 3 8 20 100 121]

x =3D

     1 3 8 20 100 121
>> y =3D fliplr(x)

y =3D

   121 100 20 8 3 1

Hope that helps

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix reversing Emeka Obe 10 Oct, 2008 11:00:20
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com