COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Moving columns below other columns, in a matrix

• Email
• 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

See related articles to this posting

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

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

```Thanks a lot!!
```
 0