From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cluster manipulation

Dear all,

My data consist of 6 array whose elements are different types(5 elements, %s/%f/%d/%f/%f) each other.
(I have to manipulate 30 elements.)
Therefore, I would like to use 6 clusters with same element order.

My question is,
I have to identify the string(first element) or sum the second elements in all 6 clusters.
In order to do this, should I unbundle the clusters?
(I mean I want to use some convenient methods as the case of array calculation)

Thank you in advance.

Lee
0 Kudos
Message 1 of 4
(2,435 Views)
I'm confused - it's not clear whether you have an array of clusters (the cluster containing six items), or a cluster of arrays (an array of each type).

Why do you want to use 6 clusters rather than 6 arrays?
0 Kudos
Message 2 of 4
(2,438 Views)
I need to handle 5 elements which are different type each other.
I made a cluster using 5 elements by bundling function.
(I was told I can't make an array because of different element data type.)
The number of cluster is 6.
(To wire 30 elements are very complex in monitor screen.)

Whenever calculate an element of cluster, it seems to unbundle the clusters.
(I think there is no advantage of clustering if I have to unbundle.)

Do you understand my situation?

Thank you in advance.
0 Kudos
Message 3 of 4
(2,421 Views)
I think I understand.

It's often good to group associated, but mixed type, data items into clusters (e.g. file records), particularly to form a single array of these clusters/records. It facilitates a more compact and better documented diagram/coding.

The downside to using arrays of clusters is that you inevitably need to both index the array and then unbundle the cluster to access individual elements. Sometimes this might seem a rather onerous task and may appear to create more block diagram functions than neccessary - but it's often still the best way, as it's very important to create logical easy to read code.

I've attached an example of the sort of data structure I think you've described - and showed two alternative ways of summing all the second cluster elements (and the two alternative unbundle options). The upper method looks nicer and may run a tiny bit faster, but the lower method is more memory efficient as it does not create a second array before summing - the difference is insignificant unless you are dealing with very large arrays.

Hope this helps.

If this isn't how your code looks, you will have to attach your code example so we can see it.
0 Kudos
Message 4 of 4
(2,397 Views)