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:
how to split a matrix

Subject: how to split a matrix

From: Timothy Koh

Date: 7 Mar, 2013 07:14:09

Message: 1 of 5

Hi

I have a <39014400x1 double> matrix. How do i go about splitting it and merge it back together?

Help is greatly appreciated

Regards
Timothy

Subject: how to split a matrix

From: James Tursa

Date: 7 Mar, 2013 07:24:09

Message: 2 of 5

"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message <kh9eo1$fmj$1@newscl01ah.mathworks.com>...
> Hi
>
> I have a <39014400x1 double> matrix. How do i go about splitting it and merge it back together?
>
> Help is greatly appreciated
>
> Regards
> Timothy

How do you want it split? E.g.,

a = rand(39014400,1);
b = a(1:1000000); % split first part
c = a(1000001:end); % split second part
d = [b;c]; % join the pieces back together

James Tursa

Subject: how to split a matrix

From: Timothy Koh

Date: 7 Mar, 2013 07:28:08

Message: 3 of 5

"James Tursa" wrote in message <kh9fap$h62$1@newscl01ah.mathworks.com>...
> "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message <kh9eo1$fmj$1@newscl01ah.mathworks.com>...
> > Hi
> >
> > I have a <39014400x1 double> matrix. How do i go about splitting it and merge it back together?
> >
> > Help is greatly appreciated
> >
> > Regards
> > Timothy
>
> How do you want it split? E.g.,
>
> a = rand(39014400,1);
> b = a(1:1000000); % split first part
> c = a(1000001:end); % split second part
> d = [b;c]; % join the pieces back together
>
> James Tursa

Thanks James Tursa. Is it possible to split it like into number of segments i want? Eg. splitting it into 20 segments.

Subject: how to split a matrix

From: Steven_Lord

Date: 7 Mar, 2013 15:28:04

Message: 4 of 5



"Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
news:kh9fi8$hqk$1@newscl01ah.mathworks.com...
> "James Tursa" wrote in message <kh9fap$h62$1@newscl01ah.mathworks.com>...
>> "Timothy Koh" <timothy_koh87@hotmail.com> wrote in message
>> <kh9eo1$fmj$1@newscl01ah.mathworks.com>...
>> > Hi
>> >
>> > I have a <39014400x1 double> matrix. How do i go about splitting it and
>> > merge it back together?
>> >
>> > Help is greatly appreciated
>> >
>> > Regards
>> > Timothy
>>
>> How do you want it split? E.g.,
>>
>> a = rand(39014400,1);
>> b = a(1:1000000); % split first part
>> c = a(1000001:end); % split second part
>> d = [b;c]; % join the pieces back together
>>
>> James Tursa
>
> Thanks James Tursa. Is it possible to split it like into number of
> segments i want? Eg. splitting it into 20 segments.

You haven't given the group sufficient information to answer definitively,
but I suspect the answer is yes. What limitations do you have on which
element goes into which segment?

First 39014400/20 elements in segment 1, next 39014400/20 elements in
segment 2, etc.?

Elements 1:20:39014400 in segment 1, elements 2:20:39014400 in segment 2,
etc.?

Elements 1 through 19 in segments 1 through 19 respectively and the rest in
segment 20?

Segments 1 through 19 each contain 1% of the data set chosen (without
replacement) at random, segment 20 contains the rest? [A division like this
might be useful in training/validation set division for neural network
training.]

See functions like RESHAPE, COLON, and RANDPERM for some of the tools that
may be useful to you depending on your chosen division method.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how to split a matrix

From: Greg Heath

Date: 16 Mar, 2013 13:34:06

Message: 5 of 5

"Steven_Lord" <slord@mathworks.com> wrote in message <khabm4$a3q$1@newscl01ah.mathworks.com>...
-------SNIP
> Segments 1 through 19 each contain 1% of the data set chosen (without
> replacement) at random, segment 20 contains the rest? [A division like this
> might be useful in training/validation set division for neural network
> training.]

Data divisions in the NNTBX can be implemented with functions

dividetrain, dividerand, divideind, divideint and/or divideblock

Hope this helps.

Greg

Tags for this Thread

No tags are associated with 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