You are here

Arrays and Clusters

26 July, 2019 - 09:47
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/5b6e61df-b830-48cb-9764-94696cb47c80@1.3

To create an array in G, right click on the Front Panel window and select Array from the Controls » Modern » Arrays, Matrix & Cluster menu, and drop the array structure onto the Front Panel window to create an array.

media/image1.png
Figure 4.1 Array Structure 

The array structure consists of an index or element offset (highlighted left portion of the array structure) and the array elements (right portion of the structure). When the array structure is placed on the Front Panel window, the data type of the array is undefined as indicated by the grayed out portion of the array.

media/image2.png
Figure 4.2 Index and Elements of an Array  

To define the array data type, drag and drop any data type, such as numeric, Boolean, string or cluster structure, onto the elements portion of the array structure.

media/image3.png
Figure 4.3 Creating Arrays  

At this point, the newly defined array is anEmpty orNullArray because no elements of the array have been defined. This is indicated by the grayed out data type within theelements array structure.

media/image4.png
Figure 4.4 Empty Arrays 

To define elements of an input array, select the element's index and enter the appropriate value. Figure 6.5 defines a numeric array with one element at index 0.

media/image5.png
Figure 4.5 Defining Array Elements 

G arrays are zero-based. The last element index of an N element array is N1. Last Array Element and Undefined Nth Element are those of a 10 element array.

media/image6.png
Figure 4.6 Last Array Element 
media/image7.png
Figure 4.7 Undefined Nth Element 

An output array is created similarly to an input array with the exception that an output data type needs to be dropped into the array structure.

media/image8.png
Figure 4.8 Input and Output Arrays