![background image](http://html1.mh-extra.com/html/national-instruments/bridgeview/bridgeview_user-manual_3445534299.webp)
Chapter 14
Arrays, Clusters, and Graphs
©
National Instruments Corporation
14-17
What is Polymorphism?
Polymorphism is the ability of a function to adjust to input data of different
types, dimensions, or representations. Most G functions are polymorphic.
For example, the following illustrations show some of the polymorphic
combinations of the Add function.
In the first combination, the two scalars are added together, and the result
is a scalar. In the second combination, the scalar is added to each element
of the array, and the result is an array. An array is a collection of data. In the
third combination, each element of one array is added to the corresponding
element of the other array. You also can use other combinations, such as
clusters of numerics or arrays of clusters.
You can apply these principles to other G functions and data types.
G functions are polymorphic to different degrees. Some functions might
accept numeric and Boolean inputs, others might accept a combination of
any other data types. For more information about polymorphism, see
Online Reference»Function and VI Reference.
Clusters
A cluster is a data type that can contain data elements of different types.
The cluster in the block diagram that you will build in Activity 14-4 groups
related data elements from multiple places on the block diagram, reducing
wire clutter. When you use clusters, your subVIs require fewer connection
terminals. A cluster is analogous to a record in Pascal or a struct in C. You
can think of a cluster as a bundle of wires, much like a telephone cable.
Each wire in the cable would represent a different element of the cluster.
The components include the initial X value (0), the delta X value (1), and
the Y array (waveform data, provided by the numeric constants on the
Result
Combination
Scalar
Array
Array + Array
Array
Array
Scalar