Example Code

Dynamically Build a Simple Array

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

 

Arrays are used to store data in a new and organized fashion. Someimtes they can be a a little tricky to manipulate to get just the way you want them to be. One solution is to make an array of a set size and fill in the values. While this process helps with memory allocation, it does not help us with creating an array that we do not know the size of. This is a simple example that should how to create an array dynamically.

 

Description

 

This example uses a shift register, build array and the random number generator to create a 3x8 array. The first collumn is a random number, the second clumn in the interation count and the third colum is a constant. There is a Wait Until Next ms Multiple timer in there to slow down the excution. This VI can be implimented with a While Loop instead of a For Loop.

 

Steps to Impliment and Execute

 

1) Download the VI

2) Observe the block diagram. Notice how the shift register is connected to the build array.

3) Run the VI and observe how it fills the array collumn by collumn

 

Requirements

 

LabVIEW 2010 or later to run VI

LabVIEW 2012 for code Snippet

 

Block Diagram Code Snippet

Dynamically Build Array.png

Kurt P
Automated Test Software R&D

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.