03-05-2018 10:27 AM
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
Solved! Go to Solution.
03-05-2018 10:43 AM
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:
03-05-2018 11:02 AM
@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.
03-05-2018 11:11 AM - edited 03-05-2018 11:12 AM
Another variation using Reshape Array and conditional concatenating tunnels.
03-05-2018 11:27 AM
@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. 😄