08-27-2015 06:43 AM
Hi All
I have a problem where i need to obtain a string for each execution of the for loop and also executing for the amount of elements in the array of clusters. so for an array holding 5 elements and the array of clusters holding 3 elements i would like an output of 18 elements/strings. I have a solution but it is very bulky(using a for loop for each index of the array of clusters, executing for each element in the array of strings) is there any way to do this using only one loop?
My solution is attached
Thanks
08-27-2015 06:52 AM - edited 08-27-2015 06:55 AM
I assume you made a typo as 5x3 = 15 not 18.
You could multiply the two dimensions together (5 and 3) and wire that to the N terminal of the for loop. You can then use 'index' array instead of auto-indexing tunnels to pick out the appropriate item from each array (e.g. using quotient and remainder) and do your operation.
Edit: Oh, having actually looked at your screenshot - why don't you have a for loop inside a for loop? (sorry, I thought you already had that and were trying to avoid it).
Also - if you create a subVI, you'll only need to edit the string manipulation once!
08-27-2015 09:10 AM - edited 08-27-2015 09:11 AM
Yes, all you need is a stack of two FOR loops. Now just build the parts in the inner loop and append.
(If your version is older, you might have to use shift registers instead of special tunnels.)