LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate cycles in a array

Hi,
I need to create a vi such that it takes in two inputs: a 2-d array and a numeric value (number of cycles), and returns a 2-d array where its first-column values increment as usually and second-column values are repeated the specified number of times. For example, if the 2d array is [0,7; 1,8; 2,9] and number of cycles is 3, then the output array is [0,55; 1,56; 2,57; 3,55; 4,56; 5,57; 6,55; 7,56; 8,57]
Is there a pre-existing vi that does this or something similar? Thanks.
Attached is what I can come up with, with two subVIs downloaded from this website. It doesn't work as I wish it would, please help. Thanks.
0 Kudos
Message 1 of 7
(3,372 Views)
Hi dathenv...
I didn't understand your Q. How did you get the second column ? From where are the numbers 55,56,57 ?
Tell me more specific how did you get them, and I will try to help you...
Message 2 of 7
(3,372 Views)
Ooooops I'm so sorry, I changed the 2nd column of the output in effort to make the question more clear, but I forgot to change the values of the 2nd column of the input. The input array should have values [0,55; 1,56; 2,57]. Output is correct.

(Originally I had 7 8 9 as the values of the 2nd column of the input array, but unfortunately if I make three cycles, 7 and 8 would appear in the first column of the output, so I thought that might confuse the reader)

Thanks in advance for you willingnes to help.
0 Kudos
Message 3 of 7
(3,372 Views)
What you really need is a 2-D array built out of two 1-D arrays. For the first 1-D array you extract the 2nd column from your 2-D array and add it to the end of itself the desired number of times (see attached example). The other array can be created by running a for loop for the number of times that there will be data points in the array and taking the array from the increment. These two array can then be combined and transposed to give the output that you want.
Message 4 of 7
(3,372 Views)
Here You Go....

Hope it Helps....
0 Kudos
Message 5 of 7
(3,372 Views)
This works! Thank you so much!!!
0 Kudos
Message 6 of 7
(3,372 Views)
Thank you!
0 Kudos
Message 7 of 7
(3,372 Views)