LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to append a series data into an array?

Hellow,i have a question,how to append a series of data into an array? for example,my program produce number 1,2,3,4... one by one,then how to show it in an 1-D array?Thanks!
0 Kudos
Message 1 of 6
(3,196 Views)
Use a shift register and the build array function or auto-index the data out of a while or for loop.
Message 2 of 6
(3,196 Views)
Can you tell me how to "auto index the array?"thanks!
0 Kudos
Message 3 of 6
(3,196 Views)
See if this answers your question. If Im not mistaking you just want to insert your data to a 1D array. I created a simple methods with indexing and one with the shift register and build array function. Hope this helps.
-Dave
0 Kudos
Message 4 of 6
(3,196 Views)
You can get more info in the on-line help and shipping examples but briefly, auto-indexing is a feature of for and while loops. If you wire an array to a for loop, each element of the array enters the for loop one a time. You do not need to use the index array fucntion to access individual elements. A scalar element exiting a for loop is automatically built into an array. This is the default behavior of for loops and the optional behavior of while loops. A quick way to create an example is to drop a for loop on a block diagram. Wire some constant to the iteration terminal (i.e. 5). Put the random number generator function inside the for loop. Wire the output of that to the edge of the for loop. Right click on the output tunnel and select C
reate Indicator. You'll see that it creates an array. If you then run the VI, the array will be populated. Auto-indexing is very effecient because the array size is allocated according to the number wired to the iteration terminal or to the size of the input array. Using a shift register and build array is less effecient becasue there's no way for LabVIEW to know the final size of the output array so additional array allocation has to be done periodically.
0 Kudos
Message 5 of 6
(3,196 Views)
More information regarding auto-indexing in loops:

KnowledgeBase 2VB69A00:Different Wiring Tunnels with For Loops and While Loops in LabVIEW

Again, using auto-indexing in loops is much more efficient than using the Build Array.vi with shift registers.

Hope this helps. 🙂
0 Kudos
Message 6 of 6
(3,196 Views)