To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example will show the user how to create an array and iterate though each cell and add a new value to it.
Description
Arrays can be tricky. The Array Palette has a lot of useful functions and it is wise to go through and understand each function. You can easily expand this to work with bigger arrays and custom data.
Requirements
Steps to Implement or Execute Code
Drop down an Initialize Array VI on the Block Diagram. Initialize all the values to 0 and create a 1 by 10 array.
Next, create a For Loop and make the iteration terminal to 10 since we just want to fill up the first 10 columns of our array.
Drop down a Replace Array Subset VI within the while loop. Wire a 0 constant to the first index position and the iteration terminal to the second index position. This will allow us to edit the first row and iterate through each column.
We then add a Random Number (0-1) function to the 'new element' input of the Replace Array Subset VI just to add values to each column as we iterate through them.
Additional Information or References
VI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.