gurj001 Posted August 15, 2004 Report Share Posted August 15, 2004 Im trying to send data to a array and want to use 'i' from the while loop as the index for the array. Ive wired it up the only way i can think of but the array is still empty after running the VI Any idea what im doing wrong?? See picture (looking at 'average weight array') Quote Link to comment
gurj001 Posted August 15, 2004 Author Report Share Posted August 15, 2004 Here the VI file Download File:post-583-1092595872.vi Quote Link to comment
James McAnanama Posted August 16, 2004 Report Share Posted August 16, 2004 It looks like you want to build an array in the loop and use the data logged in previous iterations. For persistent local storage, use a shift register. In the attached vi there are four arrays that are populated from a while loop that terminates after a set number of iterations. The first array is trivial - it is populated and autoindexed from the while loop. The second array is populated manually using a shift register and the "Insert into array" function. The third array again uses a shift register, but only populates the itself if 'i' is an even number. The final array uses two shift registers - one, is for local storage of the array (just like the above two arrays), but the second shift register stores previous values of 'i'. By right clicking on the shift register, you can add historical elements. So, the first shift register thingme on the right side of the loop is the last element stored, the next is the second last element, etc. As a result, you can keep track of variables from previous iterations. This last array only populates if the current value of 'i' is equal to the sum of the last two values (e.g. 1+2=3 - so 3 is a valid number). When the loop starts, it initializes all values. However, this is not necessary - you could make the vi reentrant and keep the value persistent for each call the this vi. Hope this helps. Cheers, James Download File:post-365-1092659541.vi Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.