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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com