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:
Extracting new matrix from original one

Subject: Extracting new matrix from original one

From: Kfupm engsub

Date: 1 Oct, 2011 11:29:13

Message: 1 of 3


Assume I have the following sample matrix:

A =

   [ 1 2 3 1 2 3 1 2 3 1 2 3
     9 6 3 8 9 5 2 8 5 7 3 8
     2 5 9 8 7 3 6 5 4 1 5 9 ]

I want MATLAB to create a new matrix containing all rows but taking

the first three columns then ignore the second three columns and then

take the third three column and so on. So, the resultant matrix is:


Anew =

   [ 1 2 3 1 2 3
     9 6 3 2 8 5
     2 5 9 6 5 4 ]


I have very large matrix but the above is only simple example

and I know how to do it manually : Anew = [ A(:,1:3) A(:,7:9) .......]

but this will take very long time.

regards

Subject: Extracting new matrix from original one

From: Bruno Luong

Date: 1 Oct, 2011 11:53:19

Message: 2 of 3

Anew = A(:,mod(ceil((1:end)/3),2)==1)

Bruno

Subject: Extracting new matrix from original one

From: Kfupm engsub

Date: 1 Oct, 2011 12:05:27

Message: 3 of 3

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <j66uvf$6v1$1@newscl01ah.mathworks.com>...
> Anew = A(:,mod(ceil((1:end)/3),2)==1)
>
> Bruno


thanks Bruno

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