Jump to content

Data from while loop into array?


Recommended Posts

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.