01-07-2012 12:34 AM
hi,
I have a while loop which has to stop after 5 iterations,in which i have 2 for loops in a while loop.Each for loop has to run 2 times each. The output of each for loop has 2 values and one value coming from the first iteration of while loop so total 5 values.Now i want to store all these values in a single 1-D array format,which i am not able to do. i am unable to store all the values in a single array .Can anyone guide me in doing this
01-07-2012 01:05 AM - edited 01-07-2012 01:10 AM
You could resize the output array or use a shift register in the second for loop instead of indexing, make sure you append the new value to the old array.
01-07-2012 10:28 AM
@Samineni wrote:
hi,
I have a while loop which has to stop after 5 iterations,in which i have 2 for loops in a while loop.Each for loop has to run 2 times each. The output of each for loop has 2 values and one value coming from the first iteration of while loop so total 5 values.Now i want to store all these values in a single 1-D array format,which i am not able to do. i am unable to store all the values in a single array .Can anyone guide me in doing this
I am not sure what you mean by "nested For loops." Nested in the while loop or one For nested inside another, which is the traditional term. The attached VI probably will not give you your expected results, but it will give you an idea of how to use indexing and shift registers to build arrays, which is your main question.
It would help if you could attach a VI so we can get a better idea of your code. You are not very clear in your original post regarding your design.
Keep in mind, there are actually two programs in the attached VI which is the reason for two stop buttons, but this was just to demonstrate different methods, not be familiar with your design.
01-07-2012 02:33 PM - edited 01-07-2012 02:48 PM
Samineni wrote:I have a while loop which has to stop after 5 iterations, ,in which i have 2 for loops in a while loop.
That means it actually should be a FOR loop, right?
@Samineni wrote:
Each for loop has to run 2 times each. The output of each for loop has 2 values and one value coming from the first iteration of while loop so total 5 values.Now i want to store all these values in a single 1-D array format,which i am not able to do. i am unable to store all the values in a single array .Can anyone guide me in doing this
If both inner for loops spin exactly twice, couldn't you place all code is a single FOR loop? Or are they nested too?
So, do you want to append 5 elements to a 1D array with every iteration of the outer loop (final size 25 elements), or do you want to overwrite a 5 element 1D array with every iteration of the outer loop (final size 5 elements)?
What should be the order of the five element sets?
As you can see, a text description is typically not sufficient to unambiguously describe a VI. it would be significantly easier for all of us if you could attach a simple draft of your code.
01-07-2012 02:44 PM - edited 01-07-2012 02:44 PM