A group of homogeneous elements of a specific data type is known as an ARRAY, one of the simplest data structures. Arrays hold a sequence of data elements, usually of the same size and same data type placed in contiguous memory locations that can be individually referenced. Hence arrays are essentially a way to store many values under the same name. Individual elements are accessed by their position in the array. The position is given by an index, which is also called a subscript. The index usually uses a consecutive range of integers. Some arrays are multi-dimensional, but generally, one-and two-dimensional arrays are the most common.
You can 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, graphs, data generated in loops or data collected from multiple sensors. LabVIEW like other conventional structured languages uses arrays and data structures (data structures include clusters and type definitions) for this purpose.
In LABVIEW arrays group data elements of the same type. They are analogous to arrays in traditional languages. An array consists of elements and dimensions. Elements are the data that make up an array. A dimension is the length, height or depth of an array. An array can have one or more dimensions and as many as (231) – 1 elements per dimension, memory permitting.
You can build arrays of numeric, Boolean, path, string and cluster data types. You cannot create arrays of arrays. However, you can use a multidimensional array or an array of clusters where each cluster contains one or more arrays. Also, you cannot create an array of subpanel controls, tab controls, .NET controls, ActiveX controls, charts or multiplot XY graphs.
Array elements are ordered. To locate a particular element in an array requires one index per dimension. For example, if you want to locate a particular element in a two-dimensional array, you need both row index and column index. In LabVIEW, indexes let us navigate through an array and retrieve elements, rows and columns from an array on the BLOCK DIAGRAM. The index is zero-based, which means it is in the range 0 to n – 1, where n is the number of elements in the array with the first element at index 0 and the last one at index (n – 1). For example, if you create an array of 10 elements, the index ranges from 0 to 9. The fourth element has an index of 3.
Get Updates on Tech posts, Interview & Certification questions and training schedules