Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reversing a row matrix

Subject: Reversing a row matrix

From: Emeka Obe

Date: 10 Oct, 2008 14:56:03

Message: 1 of 11

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 11

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

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 11

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 11

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 11

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 11

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

Subject: Reversing a row matrix

From: Abdul Hanan Sheikh

Date: 10 Jul, 2013 13:02:10

Message: 8 of 11

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


Try Matlab function wrev .

cheers,

Subject: Reversing a row matrix

From: dpb

Date: 10 Jul, 2013 13:50:30

Message: 9 of 11

On 7/10/2013 8:02 AM, Abdul Hanan Sheikh wrote:
> "Emeka Obe" 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
>
>
> Try Matlab function wrev .

doc fliplr

--

Subject: Reversing a row matrix

From: Baha

Date: 10 Jul, 2013 17:17:32

Message: 10 of 11

Easiest:
x = x(end:-1:1);
__
Baha

Subject: Reversing a row matrix

From: dpb

Date: 10 Jul, 2013 17:43:50

Message: 11 of 11

On 7/10/2013 12:17 PM, Baha wrote:
> Easiest: x = x(end:-1:1); __

I don't know,

 >> length('x=x(end:-1:1);')
ans =
     14
 >> length('x=fliplr(x;')
ans =
     11
 >>

:)

--

Tags for this Thread

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.

Contact us