2. ARRAYS
• An array consists of elements of similar data types
• Is either a control or an indicator -it cannot contain both
• Arrays are very helpful to store a history of repetitive
computations
• Array elements are ordered. Each element in an array
has a corresponding index value
• One-dimensional (1D) array contains n elements, the
index range is from 0 to n – 1
2
modern electronic instrumentation unit 4
3. •Controls palette >> Modern » Array, Matrix, & Cluster
and drag the Array shell
•Drag and drop a numeric indicator inside the Array shell
•Expand it and display multiple elements
3
modern electronic instrumentation unit 4
4. • A 2D array stores elements in a grid or matrix
• Each element in a 2D array has two corresponding index
values, a row index and a column index
• Right click on index display to add dimension
4
modern electronic instrumentation unit 4
5. • Elements of the arrays created have been dimmed zeros
• Dimmed array element indicates that the element is
uninitialized
• To initialize an element, click inside the element and
replace the dimmed 0 with any number
5
modern electronic instrumentation unit 4
6. • Change the numeric type to a 32-bit integer.
• Right-click on the array and select Representation»I32
6
modern electronic instrumentation unit 4
7. • If you wire an array as an input to a for loop, LabVIEW
provides the option to automatically set the count terminal
of the for loop to the size of the array using the Auto-
Indexing feature.
• You can enable or disable the Auto-Indexing option by
right-clicking the loop tunnel wired to the array and
selecting Enable Indexing (Disable Indexing).
• If you enable Auto-Indexing, each iteration of the for loop
is passed the corresponding element of the array.
• When you wire a value as the output of a for loop,
enabling Auto-Indexing outputs an array.
• The array is equal in size to the number of iterations
executed by the for loop and contains the output values of
the for loop.
Auto-Indexing
7
modern electronic instrumentation unit 4
8. Only initialized will be used for any operation
8
modern electronic instrumentation unit 4
9. CLUSTERS
• Clusters group data elements of mixed types.
• A cluster is similar to a record or a struct in text-based
programming languages.
• Similar to arrays, a cluster is either a control or an
indicator and cannot contain a mixture of controls and
indicators.
• The difference between clusters and arrays is that a
particular cluster has a fixed size, where a particular array
can vary in size.
• Also, a cluster can contain mixed data types, but an array
can contain only one data type.
9
modern electronic instrumentation unit 4
10. • Controls palette >> Modern » Array, Matrix, & Cluster
and drag the Cluster shell
• Add data types (numeric, string, boolean, etc)
10
modern electronic instrumentation unit 4
11. • To create cluster constant in block diagram
• Programming>>Cluster, Class, &variant, cluster constant.
• Drag and drop different data types into cluster constant
shell
11
modern electronic instrumentation unit 4
12. • If you already have a cluster control or indicator and want
to make a cluster constant that contains the same data
types,
• Make a copy of the cluster control or indicator on the
block diagram and then
• Right-click on the copy and select Change to Constant
from the shortcut menu
12
modern electronic instrumentation unit 4
13. Cluster functions often used to manipulate clusters are the
Bundle,
Unbundle,
Bundle By Name, and
Unbundle By Name functions
bundle
13
modern electronic instrumentation unit 4
14. LabVIEW Strings
• A string is a collection of ASCII characters.
• In instrument control, you may pass numeric
data as character strings then convert these
strings back to numeric to process the data.
14
modern electronic instrumentation unit 4
17. FILE I/O
• File I/O operations pass data to and from files.
• A typical file I/O operation involves three steps.
1- Create or open a file.
2- Read from or write to
3- Close the file
• Read or write on a file takes
only after opening a file
modern electronic instrumentation unit 4 17
18. • Reads or write data from an open file
specified by refnum
modern electronic instrumentation unit 4 18
Open/create/replace
Read
20. Other File I/O Functions
• Read or Write to Waveform file
• Read or Write to Spreadsheet file
– Converts contents to array (read)
- uses array to write
modern electronic instrumentation unit 4 20