Thread Subject: how to create a new matrix from a [n 1] matrix

Subject: how to create a new matrix from a [n 1] matrix

From: burcu

Date: 12 Nov, 2009 17:07:03

Message: 1 of 3

Hi all,

I have a nx1 matrix and i want to create an axb matrix from this lines by taking the first a columns and setting as column 1, taking next a columns and putting it right of the first a columns etc.
An example to be more clear:

data= a
         b
         c
         d
         e
         f
         g
         h
i have 8x1 matrix and i need to get a 2x4 matrix from this like:
             a c e g
             b d f h
Any advice to create such a matrix for a really big number of n?

Thanks for all the replays!

Burcu

Subject: how to create a new matrix from a [n 1] matrix

From: Dips Bhatia

Date: 12 Nov, 2009 17:18:02

Message: 2 of 3

"burcu " <burcu102@hotmail.com> wrote in message <hdhfbn$m36$1@fred.mathworks.com>...
> Hi all,
>
> I have a nx1 matrix and i want to create an axb matrix from this lines by taking the first a columns and setting as column 1, taking next a columns and putting it right of the first a columns etc.
> An example to be more clear:
>
> data= a
> b
> c
> d
> e
> f
> g
> h
> i have 8x1 matrix and i need to get a 2x4 matrix from this like:
> a c e g
> b d f h
> Any advice to create such a matrix for a really big number of n?
>
> Thanks for all the replays!
>
> Burcu

Use reshape(data,2,4)
See help reshape

Subject: how to create a new matrix from a [n 1] matrix

From: burcu

Date: 12 Nov, 2009 17:40:22

Message: 3 of 3

Thanks Dips, exactly what i want.
Burcu

"Dips Bhatia" <deepakdbhatia@gmail.com> wrote in message <hdhg0a$2ke$1@fred.mathworks.com>...
> "burcu " <burcu102@hotmail.com> wrote in message <hdhfbn$m36$1@fred.mathworks.com>...
> > Hi all,
> >
> > I have a nx1 matrix and i want to create an axb matrix from this lines by taking the first a columns and setting as column 1, taking next a columns and putting it right of the first a columns etc.
> > An example to be more clear:
> >
> > data= a
> > b
> > c
> > d
> > e
> > f
> > g
> > h
> > i have 8x1 matrix and i need to get a 2x4 matrix from this like:
> > a c e g
> > b d f h
> > Any advice to create such a matrix for a really big number of n?
> >
> > Thanks for all the replays!
> >
> > Burcu
>
> Use reshape(data,2,4)
> See help reshape

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com