LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing help

Solved!
Go to solution

Hello

I am looking for a quick way of indexing in groups. That is for example I have an array of 100 elements and I want to index it as follows.

I want to create two groups. 

First group: 1,2,3,4,9,10,11,12,17,18,19,20,25,26,27,28,....

Second Group, 5,6,7,8,13,14,15,16,21,22,23,24,29,30,31,32

note: number is the index in the 100 element array

So that would be 2 groups of 50 each but indexed as it follows. I am not sure if there is a quick way of doing this through for loops.

 

Thank you

0 Kudos
Message 1 of 5
(2,727 Views)
Solution
Accepted by topic author seb1509

There are many ways to do this. In newer LabVIEW versions, you have the conditional tunnel, so that would give a simple solution, e.g. as follows:

 

SplitArray.png

Message 2 of 5
(2,720 Views)

@seb1509 wrote:

Hello

I am looking for a quick way of indexing in groups. That is for example I have an array of 100 elements and I want to index it as follows.

I want to create two groups. 

First group: 1,2,3,4,9,10,11,12,17,18,19,20,25,26,27,28,....

Second Group, 5,6,7,8,13,14,15,16,21,22,23,24,29,30,31,32

note: number is the index in the 100 element array

So that would be 2 groups of 50 each but indexed as it follows. I am not sure if there is a quick way of doing this through for loops.

 

Thank you


I don't think you'd get 2 groups of 50.  100 is not divisible by 8.  Because of your 4 ON, 4 Off pattern, your first group will have 52 numbers, your second will have 48.

 

100 is not divisible by 8.

Message 3 of 5
(2,705 Views)

Another variation using Reshape Array and conditional concatenating tunnels.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(2,694 Views)

@crossrulz wrote:

Another variation using Reshape Array and conditional concatenating tunnels.


That only works if there is no remainder for the division, else the last elements will get truncated. My solution maintains the pattern irrespective of input size and will create unequal output sizes if needed. Probably a more universal solution. 😄

Message 5 of 5
(2,687 Views)