One - Dimensional Array
Create an Array control or indicator on the Front Panel by placing an array shell on the front panel as shown in below Figure (a), and dragging a data object or element, which can be a numeric, Boolean, string, path, refnum, or cluster control or indicator, into the array shell. The array shell automatically resizes to accommodate the new object. The array shell can be selected from Controls >> Modern >> Arrays, Matrix & Clusters palette. The array elements must be Controls or Indicators. You must insert an object in the array shell before you use the array on the Block diagram. Otherwise, the array terminal appears black with an empty bracket. After placing an element in the array shell, you can expand the array either horizontally or vertically to see more elements. Once a data type is assigned to the array shell, the block diagram takes the color and lettering (In [ ] brackets) of the data type. For example, if the data type is a numeric indicator, the color will be orange with [DBL] written inside the terminal. Arrays can be identified easily by their thicker (or double) wires. The below Figure (b) shows an array of numeric controls and the array has four elements. The below Figure (c) shows an array of numeric indicators.
If you would like to Enrich your career with an Android certified professional, then visit Mindmajix - A Global online training platform: “LabVIEW training” Course.This course will help you to achieve excellence in this domain.
The index ranges from 0 to 3. The first element in the array (9) is at index 0, the second element (7) is at index 1, the third element (3) is at index 2 and the fourth element (5) is at index 3. In an array the element selected in the index display always refers to the element shown in the upper-left corner of the element display. In below Figure, the element (9) at index 0 is not shown in the array, because index 1 is selected in the index display. If you want to see the element 9 again, the index value in the index display should be changed to 0.
You can create an array constant on the Block Diagram by combining an array with a valid constant, which can be a numeric, Boolean, string, path, refnum, or cluster constant. The element cannot be another array. Following are the steps for creating an array constant in the block diagram.
- Select an array constant from Functions>>Programming>>Arrays palette; place the array shell on the block diagram. The array shell appears, with an index display on the left, an empty element display on the right, and an optional label.
- Place a constant in the array shell. For example, a numeric constant in the array shell.
- The array shell automatically resizes to accommodate the object you place in the array shell. When an object is placed in the array shell, the data type of the array constant is defined.
- An alternative method of creating array constant is to copy or drag an existing array on the front panel to the block diagram to create a constant of the same data type.
Subscribe to our youtube channel to get new updates..!
You can use an array constant to store constant data or as a basis for comparison with another array. Array constants are also useful for passing data into a subVI. The above Figure (d) shows an array of Boolean constants.
Two - Dimensional Arrays
A two-dimensional array is analogous to a spreadsheet or table. A two-dimensional array stores elements in a grid. It requires a column index and a row index to locate an element, both of which are zero-based. Two-dimensional arrays are very commonly used in data acquisition applications. For example, when waveforms from several channels are read from a data acquisition (DAQ) board, the data is stored in a two-dimensional array where each column in the array corresponds to data from one channel. To create a two-dimensional array on the front panel, right-click the index display of the array and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display to have one more dimension. The below Figure shows a two-dimensional array.
Multi Dimensional Arrays
To create a multidimensional array on the Front Panel, right-click the index display of the array and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many dimensions as you want. To delete dimensions one at a time, right-click the index display and select Remove Dimension from the shortcut menu. You can also resize the index display to delete dimensions. Use the Positioning tool to resize the array to show more than one row or column at a time. To display a particular element on the front panel, either type the index number in the index display or use the arrows on the index display to navigate to that number. You can also use the scroll bars of an array to navigate to a particular element. Right-click the array and select Visible Items» Vertical Scrollbar or Visible Items»Horizontal Scrollbar from the shortcut menu to display scroll bars for the array as shown in the below Figure.