Professional Documents
Culture Documents
Short Term Course On Labview: PEC - Deemed University Lecture-4 (5 NOV, 2006)
Short Term Course On Labview: PEC - Deemed University Lecture-4 (5 NOV, 2006)
BY
Arrays
Collection of data elements that are of same type One or more dimensions, up to 2 -1 elements per dimension A dimension is the length, height, or depth of an array Elements accessed by their index First element is index 0
31
1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7
0 0 1 2 3 4
Arrays contd
Arrays can be build of numeric, Boolean, string, and cluster data types. Consider using arrays when you work with a collection of similar data. 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. You cannot create an array of arrays. However, you can create an array of clusters, where each cluster contains one or more arrays.
Creating 2D Arrays
Inner loop creates column elements Outer loop stacks them into rows
Initialize Array
Array Subset
Extracting an Element
Extracting a Row
Function inputs can be of different types All LabVIEW arithmetic functions are polymorphic
Combination Scalar + Scalar Array + Scalar Array + Array Array + Array
5 2 1 4 2 2 3 2 5 1 4 2 1 4 2 3 2 5 7 4 6 7 7
Polymorphism
3 6 4
4 6 7
Clusters
Data structure that groups data together Data may be of different types Analogous to record in Pascal or struct in C Elements must be either all controls or all indicators Thought of as wires bundled into a cable
15
16
Cluster Constants
Select a Cluster Constant shell from the Cluster subpalette Right-click on existing cluster and select Create>>Constant
Cluster Order
Elements have a logical order (start with 0) To change order, right-click on border and select Reorder Controls in Cluster...
18
19
Cluster Functions
In the Cluster subpalette of the Functions palette Can also be accessed by right-clicking on the cluster terminal
Bundle By Name
20
Cluster Functions
Unbundle
Unbundle By Name
22
Summary
An array is a collection of elements of same data type numeric, Boolean, string, etc. Creating array or cluster controls/indicators is a two-step process 1. Get array or cluster shell 2. Place desired control/indicator inside the shell Loops can accumulate arrays at boundaries auto-indexing Array functions are in Array subpalette of Functions palette LabVIEW arithmetic functions are polymorphic input different data types Clusters group data that can be different types The Bundle and Unbundle functions are used to create and disassemble clusters