cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to split an array into two using while loop?

UKMan
1-Newbie

How to split an array into two using while loop?

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

1 ACCEPTED SOLUTION

Accepted Solutions
MikeArmstrong
5-Regular Member
(To:UKMan)

Something like the attached?

Mike

View solution in original post

7 REPLIES 7
MikeArmstrong
5-Regular Member
(To:UKMan)

Something like the attached?

Mike

thanks a lot mike

ill check it out now

MikeArmstrong
5-Regular Member
(To:UKMan)

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

Ex.jpg

Mike

Thank you

For your hopeful amusement if not edification ...

I've added a couple of new 'timer' functions Counter1 and Counter2 that allow the user to specify how long to keep repeating a function and return the number of iterations. This is in contrast to Timer1 and Timer2 which allow the user the specify the number of iterations and return the time it took.

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Very nice as usual.

Surprising how slow the submatrix function is.

Mike

Hi Mike,

I suppose 'slow' is a relative term. It's comparable to iteration for small data sets, but for the larger ones it's about 25 times faster on my machine.

Stuart

Top Tags