Array for cluster - cardinality not as expected

I've played with the most basic features of LabVIEW, such as converting single items to arrays and clusters, back and forth. (Don't question the use of the algorithm shown, it isn't.)

When converting a cluster (of similar types) to an array, using this for a simple math operation and converting it back to a cluster, the cluster difference occurs in its individual elements behaving strangely. By merging the junction with this existing cluster, it automatically grows its size to 9 instead of expected. 3. Probes and numeric indicators show that the elements above the first three elements are zero.

Why is this? I would expect the array in the cluster to know the size of the transformed array and match the cluster accordingly.

enter image description here

enter image description here

+3


source to share


1 answer


While you might expect Array To Cluster to automatically apply the array size to the cluster, it instead uses a fixed default, regardless of the size of the underlying array:

The default is nine. The maximum cluster size for this feature is 256.

Source: http://zone.ni.com/reference/en-XX/help/371361J-01/glang/array_to_cluster/



This value can be changed by right-clicking the function and choosing Cluster Size from the context menu. Unfortunately, this also means fixing it manually every time the array changes.

Explanation: The reason for this behavior is that although the size of the array can change dynamically at runtime, the cluster data structure is fixed at compile time (LabVIEW is a strongly typed language). The compiler needs to be told the size of the cluster. If you really need to create arbitrary clusters at runtime, you can probably do something with the options, but I would take another look at what you are trying to achieve to see if this is really necessary.

+3


source







All Articles