LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster/Array Conversion

Hi, is there a method or is possible to convert two arrays of (8 bit unsigned) integers into a clusters with the exact number of individual numeric elements in the clusters as there was in the array and then append the two new clusters into another cluster.    
0 Kudos
Message 1 of 5
(2,690 Views)
No... you need to know the cluster size in advance if you are converting an array to a cluster.

In most cases, arrays are better to use for storage when the elements are identical.  They are much easier to manipulate than clusters when you have an undetermined amount of data.  Use clusters when a fixed set of elements are not identical (when different types of controls need to be grouped for example).

You gave little information on your exact problem but perhaps it would be better just to bundle the two arrays as-is into a cluster.
0 Kudos
Message 2 of 5
(2,684 Views)
The VIs in the cluster palette can easily do this for you. The Array to Cluster VI requires that you tell it how many elements to take (by right clicking it) because a cluster has to have a fixed number of elements.

___________________
Try to take over the world!
0 Kudos
Message 3 of 5
(2,680 Views)
Another note:  My first post assumed that you don't know what "the exact number of individual numeric elements" there are in the array--ie, you want to convert any sized array to a cluster containing the same number of elements, which is not possible.  If you know how many elements there will be in the array however, tst's post is accurate.
0 Kudos
Message 4 of 5
(2,677 Views)

The question of whether to use arrays or clusters goes beyond whether or not the values are of the same datatype. Conceptually, a 1D array is a vector--an ordered set of numbers that together in aggregate represent something--like an analog waveform or a change in temperature over time. A cluster represents a group of distinct values.

For example, consider with three values: MyWeight, WifesWeight and DaughtersWeight. All three values are floats so they could be represented by a 3-element array. However, what vector quantity would that array be representing? As a vector, those three values are meaningless. The proper representation would be as a cluster because a cluster accurately models the data's structure--three distinct values.

The important thing when developing the data representations for a program is to model the data's inherent structure in the datatype that you use to hold it. Do that well and writing the code gets much easier. What's more, you'll never have to worry about whether appropriate tools exist to manipulate the data.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(2,659 Views)