Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Index Array Function

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Owning Palette: Array Functions

Requires: Base Development System

Returns the element or subarray of n-dimension array at index.

When you wire an array to this function, the function resizes automatically to display index inputs for each dimension in the array you wire to n-dimension array. You also can add additional element or subarray terminals by resizing the function. The connector pane displays the default data types for this polymorphic function.

Details  

n-dimension array can be an n-dimensional array of any type. If n-dimension array is an empty array, element or subarray returns the default value of the defined data type for the array.
index 0..n-1 must be numeric. The number of index inputs matches the number of dimensions in n-dimension array.

If the index is out of range (<0 or N, where N is the size of n-dimension array), element or subarray returns the default value of the defined data type for the array.

Array functions in LabVIEW access array data in row-major order. In a 2D array, row is the first, major index. Column is the last, minor index. In bigger multidimensional arrays, column remains the last index and the more major indexes are added to the front. Thus, vol is the first index, followed by page, row, and column. These names are index identifiers and have no other meaning.

You can extract a subarray of the array by leaving one or more of the index terminals unwired. For example, extract column 1 of a 2D array by specifying 1 in the column index and leaving the row index unwired. If you index a 1D array and do not wire anything to the index input terminal, the Index Array function extracts the first element of the array. If you expand the node to show more than one element or subarray output, the function extracts the first number of elements equal to the number of element or subarray outputs. If you wire indexes only for some element or subarray outputs, the function extracts the index after the last wired index for the elements without wired indexes, and continues in order until the next element or subarray output with a wired index.

For example, if you wire a 2D array to the Index Array function, expand the node to show three outputs, wire 3 to the row index for the first output, and leave all other indexes unwired, Index Array outputs subarray rows 3, 4, and 5. If you wire 3 to the column index, Index Array outputs subarray columns 3, 4, and 5. If you wire 3 to both indexes, Index Array outputs the array elements at [3,3], [3,4], and [3,5].
element or subarray has the same type as the elements of n-dimension array.

Index Array Details

You can disable indexing along a dimension by leaving the corresponding index input unwired, unless you are indexing a 1D array. By default, the first dimension has indexing enabled, with the others disabled. If disabled, the input terminal is an outlined black rectangle. If enabled, it is filled. You can wire a constant or control to the index inputs that you want enabled.

For example, if you want to index a row in a 2D array, the first index input is enabled and the second index input is disabled. If you want to index that same 2D array also by column, you can resize the function to show another set of input terminals. This next set of inputs has its own corresponding subarray output. By default, if you do not wire any index input terminals, the first subarray indexes row 0, the second subarray indexes row 1, and so on.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit