Skip to main content
1-Visitor
December 3, 2010
Solved

How to split an array into two using while loop?

  • December 3, 2010
  • 1 reply
  • 5086 views

Alright so I have a data set that when graphed produces 2 peaks or are two distributions..

i want to split the graph in two...

for example if the data set is

set= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]

and i want to spit it into two vectors.. say till element 13.. so that the split looks like this

set1 = [1,2,3,4,5,6,7,8,9,10,11,12,13]

and

set2 = [14,15,16,17,18,19,20,21,22,23,24,25]

will a while loop work for this? or is there a better method

i tried with while loop but the syntax i used just sums up till element 13. 😕

update:

k so just thinking out loud here but shouldnt the following just simply split the vector:

set[0;set[d

where d is set to the mid point (13th value)

i tried that but it only gives me the value at 0.. that is set[0

Best answer by MikeArmstrong

Something like the attached?

Mike

1 reply

1-Visitor
December 3, 2010

Something like the attached?

Mike

UKMan1-VisitorAuthor
1-Visitor
December 3, 2010

thanks a lot mike

ill check it out now

1-Visitor
December 3, 2010

Oh, by the way it can be done using a while loop, but can be donw alot easier.

Ex.jpg

Mike