Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to split a matrix
Date: Thu, 7 Mar 2013 10:28:04 -0500
Organization: MathWorks
Lines: 56
Message-ID: <khabm4$a3q$1@newscl01ah.mathworks.com>
References: <kh9eo1$fmj$1@newscl01ah.mathworks.com> <kh9fap$h62$1@newscl01ah.mathworks.com> <kh9fi8$hqk$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="UTF-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1362670084 10362 172.28.9.169 (7 Mar 2013 15:28:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 7 Mar 2013 15:28:04 +0000 (UTC)
In-Reply-To: <kh9fi8$hqk$1@newscl01ah.mathworks.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: news.mathworks.com comp.soft-sys.matlab:790550



"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