Organizing Related Data in Variables (MathScript RT Module)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

You can use structures, or structs, to organize related data in variables. The following example shows how to define a structure with multiple fields that describe a point within a graph or plot:

point.x = 3.0;

point.y = 4.0;

point.color = 'blue';

In this example, point is a scalar structure with three fields: x, y, and color. Each field has an assigned value of either numeric or string data type.

Defining Structure Arrays

You can define structure arrays in which each element is a structure with multiple fields. The following example shows how to define two structure elements that describe points:

point(1).x = 3.0;

point(1).y = 4.0;

point(1).color = 'blue';

point(2).x = 3.5;

point(2).y = 5.0;

point(2).color = 'green';

Comparing Structures to Clusters

You can pass a LabVIEW cluster into the MathScript Node, and it becomes a structure in the MathScript environment. MathScript structures differ from LabVIEW clusters in the following ways:

  • Different elements in an array of structures can have different sets of fields.
  • Field names must begin with an alphabetic character and can contain only alphanumeric characters and underscores.
  • Fields in different elements of structure arrays can contain different data types; however, there are restrictions to this behavior.

Refer to the MathScript - Quantum Mechanics.lvproj in the labview\examples\MathScript directory for an example of using structs and using an array of structs.


Not Helpful