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:
swap matrix

Subject: swap matrix

From: apit

Date: 31 Mar, 2010 08:54:04

Message: 1 of 5

i have the question about the example of the coding to flip the matrix A = 1 2 3 4 5
                                                                                                        1 2 4 5 6
                                                                                                        3 4 5 6 7
                                                                                                        4 3 2 1 4
                                                                                                        3 4 2 4 5

to be matrix A = 5 4 3 2 1
                        6 5 4 2 1
                        7 6 5 4 3
                        4 1 2 3 4
                        5 4 2 4 3

Subject: swap matrix

From: Sadik

Date: 31 Mar, 2010 09:58:02

Message: 2 of 5

Hi Apit,

fliplr(A)

Best.

Subject: swap matrix

From: apit

Date: 31 Mar, 2010 11:43:04

Message: 3 of 5


can u give one example for flip column 1 and column 3?...

"Sadik " <sadik.hava@gmail.com> wrote in message <hov6ba$c06$1@fred.mathworks.com>...
> Hi Apit,
>
> fliplr(A)
>
> Best.

Subject: swap matrix

From: Sadik

Date: 31 Mar, 2010 12:12:05

Message: 4 of 5

Sure.

columnIndices = 1:size(A,3);

columnIndices(3) = 1;
columnIndices(1) = 3;

% so that columnIndices = [3 2 1 4 5 6 7 ...

newA = A(:,columnIndices);

Best.

Subject: swap matrix

From: Sadik

Date: 31 Mar, 2010 12:17:05

Message: 5 of 5

I am making lots of typos today, sorry. :)

columnIndices = 1:size(A,3);

should have been

columnIndices = 1:size(A,2);

Best.

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