Programmatically Inserting Elements, Rows, Columns, and Pages into Arrays
- Updated2025-03-11
- 2 minute(s) read
Programmatically Inserting Elements, Rows, Columns, and Pages into Arrays
You can insert an element, row, column, or page into an array programmatically. What you can insert depends on how many dimensions the array has. For example, you can insert a row or a column into an array of two or more dimensions, but you cannot insert an element. You can insert a page into an array of three or more dimensions, but you cannot insert an element, row, or column.
Complete the following steps to insert elements, rows, columns, or pages in an array.
- Add an Insert Into Array function to the block diagram.
- Wire an array of any dimension to the n-dim array input of the Insert Into Array function. The function automatically resizes based on the dimensions of the array.
- Determine which operation you want to perform from the following table and complete the associated steps.
Array wired to n-dimension array | Inserting | Complete these steps. |
---|---|---|
1D array | Element | Wire a value 0 through n to index. Wire a value to new element/subarray. |
1D array to row or column | Wire a value 0 through n to index. Wire a 1D array to new element/subarray. | |
2D array | Row | Wire a value 0 through n to index (row). Wire a 1D array to new element/subarray. |
Column | Wire a value 0 through n to index (column). Wire a 1D array to new element/subarray. | |
2D array (rows and columns) | Wire a value 0 through n to index (row) or index (column). Wire a 2D array to new element/sub array. | |
3D through n D array | Page | Wire a value 0 through n to index (page). Wire a 2D array to new element/sub array. |
3D array (pages) | Wire a value 0 through n to index (page). Wire a 3D array to new element/sub array. |
- Resize the Insert Into Array function to insert another element(s), row(s), column(s), or page(s) in an array and repeat steps 2 and 3.
- Run the VI.
If the dimension size of the array you insert is smaller than the dimension size of the array you wired to the n-dim array input of the Insert Into Array function, the function pads the array you insert with default data, such as zeros in the case of an array of numeric values.
If the dimension size of the array you insert is larger than the dimension size of the array you wired to the n-dim array input of the Insert Into Array function, the function crops the array from the end.