Moving columns below other columns, in a matrix

  • Follow


Hi everyone! 

Say I have a 6x6 matrix - what is the easiest way of moving the rightmost 3 columns below the leftmost 3 columns, such that the matrix becomes 12x3? 

Thanks for any help!
0
Reply Catalin 5/5/2010 10:51:06 PM

On May 5, 3:51=A0pm, "Catalin Eberhardt" <longtal...@gmail.com> wrote:
> Hi everyone!
>
> Say I have a 6x6 matrix - what is the easiest way of moving the rightmost=
 3 columns below the leftmost 3 columns, such that the matrix becomes 12x3?
>
> Thanks for any help!

A =3D magic(6);
B =3D [A(:,1:3);A(:,4:6)]

or:
B =3D [reshape(A(:,1:3:end),[],1) reshape(A(:,2:3:end),[],1) reshape(A(:,
3:3:end),[],1)]


-Nathan
0
Reply Nathan 5/5/2010 11:09:04 PM


Catalin Eberhardt wrote:

> Say I have a 6x6 matrix - what is the easiest way of moving the 
> rightmost 3 columns below the leftmost 3 columns, such that the matrix 
> becomes 12x3?

Easiest:

[C(:,1:3);C(:,4:6)];

More generally:

[C(:,1:end/2);C(:,end/2+1:end)]
0
Reply Walter 5/5/2010 11:12:05 PM

Thanks a lot!!
0
Reply Catalin 5/5/2010 11:17:04 PM

3 Replies
551 Views

(page loaded in 0.064 seconds)

Similiar Articles:













7/24/2012 8:43:01 AM


Reply: