LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)

Until now, we've dealt with scalar numbers only (a scalar is simply a data type that contains a single value, or "non-array"), and now it's time to move onto something more powerful and compound. A LabVIEW array is a collection of data elements that are all the same type, just like in traditional programming languages. An array can have one or more dimensions, and up to 231-1 elements per dimension (memory permitting, of course). An array data element can have any type except another array, a chart, or a graph.

Array elements are accessed by their indices; each element's index is in the range 0 to N-1, where N is the total number of elements in the array. The one-dimensional (1D) array shown here illustrates this structure. Notice that the first element has index 0, the second element has index 1, and so on.

Index

0

1

2

3

4

5

6

7

8

9

10-Element Array

12

32

82

8.0

4.8

5.1

6.0

1.0

2.5

1.7

You will find that waveforms (and many other things) are often stored in arrays, with each point in the waveform comprising an element of the array. Arrays are also useful for storing data generated in loops, where each loop iteration generates one element of the array.

Категории