Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Reversing a row matrix
Date: Sat, 23 May 2009 18:35:01 +0000 (UTC)
Organization: Univ of Newcastle upon Tyne
Lines: 43
Message-ID: <gv9fkl$g84$1@fred.mathworks.com>
References: <gcnqe3$s7h$1@fred.mathworks.com> <988983f9-5513-4057-b431-2fb44a707ca7@w39g2000prb.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1243103701 16644 172.30.248.35 (23 May 2009 18:35:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 23 May 2009 18:35:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 139991
Xref: news.mathworks.com comp.soft-sys.matlab:542051


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