Thread Subject: Reversing a row matrix

Subject: Reversing a row matrix

From: Emeka Obe

Date: 10 Oct, 2008 14:56:03

Message: 1 of 7

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 7

"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 7

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 7

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 7

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

Subject: Reversing a row matrix

From: Muma Kaba

Date: 23 May, 2009 18:35:01

Message: 6 of 7

If you intend to flip an nxm matrix; proceed as follows:

%% flip a matrix vertically
Let A be an nxm matrix
B = size(A); %finds the number of rows and columns in the matrice

for i = 1:B(2); %for i = 1 to the number of columns
    for j = 1:B(1) %for j = 1 to the number of rows
        NEW_MAP(j,i)=[A((B(1)+1)-j,i)] %this simply flips the order of the row entries.
    end
end


Regards,

Muma
swgillan <swgillan@gmail.com> wrote in message <988983f9-5513-4057-b431-2fb44a707ca7@w39g2000prb.googlegroups.com>...
> 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

Subject: Reversing a row matrix

From: Srikumar Murthy

Date: 12 Sep, 2009 13:25:04

Message: 7 of 7

y=flipdim(x,2)

see help flipdim.m for more info.

Srikumar


"Emeka Obe" <obeway@gmail.com> wrote in message <gcnqe3$s7h$1@fred.mathworks.com>...
> 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

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
inverting a matrix Srikumar Murthy 12 Sep, 2009 09:29:07
reversing a matrix Srikumar Murthy 12 Sep, 2009 09:29:07
flip matrix Muma Kaba 23 May, 2009 14:39:21
rotate matrix Muma Kaba 23 May, 2009 14:39:21
matrix reversing Emeka Obe 10 Oct, 2008 11:00:20
rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com