Create a 2D Array in LabVIEW

Updated Oct 21, 2020



  • LabVIEW

When adding an array to your LabVIEW VI, it is by default a 1-D array. This tutorial will show you have to manipulate the initial array to be a 2D array, both from the LabVIEW Front Panel and using the Initialize Array function on the Block Diagram.

Front Panel

  1. Launch LabVIEW and open a VI
  2. Right-click on the front panel and add the Controls >> Data Containers >> Array to your front panel, then define its data type.
  3. Add a dimension to an array by either:
    • Right-clicking on the index display (to the left of the array) >> select Add Dimension from the shortcut menu.
    • Dragging the index display until the number of index displays matches the desired number of dimensions. (i.e. For a 2-D array, drag until 2 displays are visible)

Block Diagram

  1. Launch LabVIEW and open a VI.
  2. Right-click on the block diagram and add the Array >> Initialize Array function.
    • By default, the Initialize Array function is set up to create a 1-D array.
  3. Left-click the Initialize Array function so the blue resizing nodes appear. 
  4. Click and drag the bottom blue node to resize the function until you have the number of dimensions you need shown. (i.e. For a 2-D array, drag until 2 displays are visible)
  5. Define the number of elements you would like in each dimension. 
    1. Right-click the first dimension size input >> Create Constant to define the number of rows in your array.
    2. Right-click the second dimension size input >> Create Constant to define the number of columns in your array.
  6. Add a constant of your desired data type to the element input. This will fill in all elements throughout your array.
    • In the example below, there are 5 rows and 2 columns defined in the 2D array. The array will be filled with string datatype elements, initialized to all say "hello."
  1. Right-click the initialized array output of the function and select Create Indicator.
  2. On the front panel, hover over the bottom-left resizing node of the array indicator until the multi-dimensional array resizing node appears. Resize array.
    • Resizing to larger than your specified dimensions is fine. When the program is run, only the array elements within your specified row and column dimensions will be initialized.
  3. Run the VI to initialize your 2D array.