Beruflich Dokumente
Kultur Dokumente
Arrays
Use arrays to collect and organize elements of the same data type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array.
Arrays
You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. Consider using arrays when you work with a collection of similar data and when you perform repetitive computations. Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration of a loop produces one element of the array.
Arrays
Row Index Column Index
2-D array: N x M Read: N by M, implies N rows and M columns (some may not be shown). Indices start counting at 0.
Column (column index = 1)
Row
(row index = 3) 3-D or greater have more index controls, but the view remains 2-D (row and column controls move to bottom).
Element
(index = 5,3)
Arrays
8 x 3 array of numerics
Do not count these that are grayed outthey are uninitialized
Also, if you try to index past the bounds, the default data value is assumed
Arrays
1-D arrays (sometimes called vectors) can be visualized and shown as a single row or a single column. However, when built into 2-D arrays, 1-D arrays become rows. Therefore, it is most expedient to think of a 1-D array as a single row, regardless of the way it is shown on the front panel.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
To create an array on the front panel, select the array shell from the palette, and then drag the desired element type into it. Add/delete dimensions by expanding the index control, or right-click and select Any property changes made to one element in the array apply to all elements.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
In a similar fashion, one way to create an array on the block diagram is to select the array constant shell from the palette, and then drag the desired element type into it.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
Also, as previously discussed, arrays can be automatically constructed by enabling indexing in loops. Indexing is also useful for deconstructing an array for element-by-element processing.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
Finally, the full complement of functions available on the Array palette can be used for all sorts of creation and processing tasks. One example: Initialize Array.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
Note padding
Another example is Build Array, which can be used in two ways: to append arrays of dimensions N and N-1, or to concatenate if all are of the same dimension. If all are of dimension N, then the appended array is of dimension N+1.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
Like many of the array functions, Build Array can be expanded to allow for any number of inputs; and the input glyphs change to mimic the wired input dimensions.
John D. Wellin Dept. of Mechanical Engineering, RIT
Arrays
Index Array: select individual elements, rows, columns, etc. from higher-dimensional arrays. Note expansion and glyph concepts, as well as the adaptive terminals 3-D Version
page index
row index
column index
Arrays
Use the standard, polymorphic numeric functions with arrays as well, which work on an element-by-element basis. Note that these are not the typical matrix operations that mathematicians speak of. There is also the special function Add Array Elements, and Multiply Array Elements.
Arrays
The typical mathematical operations for matrices are found under the All Functions>>Analyze>>Mathematics>>Linear Algebra palette.
John D. Wellin Dept. of Mechanical Engineering, RIT
Clusters
Clusters group data elements of mixed types. An example of a cluster is the LabVIEW error cluster, which combines a Boolean value, a numeric value, and a string. Another example is the Waveform data type, which is essentially a specialized cluster of a start time, a time increment, and a 1-D array of numerics.
Most clusters on the block diagram have a pink wire pattern and data type terminal. Clusters of numeric values, sometimes referred to as points, have a brown wire pattern and data type terminal. You can wire brown numeric clusters to numeric functions to perform the same operation simultaneously on all elements of the cluster.
Clusters
This one cluster contains numeric, boolean, and string data types altogether. The associated terminal is pink because of the mixed types. Note that all of the objects are assigned the same functionality as control or indicator, and cannot be mixed in this manner.
John D. Wellin Dept. of Mechanical Engineering, RIT
Clusters
To create a cluster on the front panel, select the cluster shell from the palette, and then drag the desired elements into it. The elements are arranged in the cluster in the same order in which they are addedbut this arrangement can be changed.
SEE NEXT!
John D. Wellin Dept. of Mechanical Engineering, RIT
Clusters
Reordering elements of a cluster
Right-click
Clusters
The ordering of the elements is important, because it is according to the order that the elements are read from or written to.
The Bundle function: use to create or modify a cluster, following the order assignedyou must make it match!
John D. Wellin Dept. of Mechanical Engineering, RIT
UNLESS
Clusters
If the cluster contains elements with owned labels, then the Unbundle by Name function does not need to know the ordering. This does not work with cluster constants, and has the Bundle by Name twin
Clusters
Original cluster control Unbundle by Namehere fully expanded, but only one element is wired.
separate control
separate indicator
Bundle by Namehere used to modify only one named element of the original cluster (names come from the cluster)
John D. Wellin Dept. of Mechanical Engineering, RIT
Clusters
The rest of the cluster functions
Cluster-array conversions: shows the connection between clusters and 1-D arrays
John D. Wellin Dept. of Mechanical Engineering, RIT
status is a Boolean value that reports True if an error occurred. Most VIs, functions, and structures that accept
Boolean data also recognize this parameter. For example, you can wire an error cluster to the Boolean inputs of the Stop, Quit LabVIEW, or Select functions. If an error occurs, the error cluster passes a True value to the function.
code is a 32-bit signed integer that identifies the error numerically. A non-zero error code coupled with a status of False signals a warning rather than a fatal error. source is a string that identifies where the error occurred.
John D. Wellin Dept. of Mechanical Engineering, RIT