LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set elements in typedef cluster of double arrays

Solved!
Go to solution

Hello,

 

I have a type def cluster. This cluster includes 16 double arrays, the size of the arrays are identical, but can change during runtime.

 

I would like to write array data to this cluster in a FOR loop, where I get the arrays during the iterations from a TDMS file. So the for loop will iterate 16 times, and each time I should set one element of the above cluster to be the recent read double array.

 

What would be the most simple solution here, since I cannot use here the "Cluster to array" and Array to cluster VIs...?

 

thanks!

 

0 Kudos
Message 1 of 8
(3,865 Views)

I guess you would unbundle the controls arrays?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 8
(3,861 Views)

Ok, I use the "unbundle by name" --> I get 16 double array wires. I could build a 2D array from these, tunel it into the for loop, and I can write data to each of these in the for loop.

After this, I have to index out the 16 arrays from the new 2D array, and wire these 16 wires to the sinks of the Bundle by name.

 

I would like to avoid the above effort...

0 Kudos
Message 3 of 8
(3,854 Views)

@Blokk wrote:

Ok, I use the "unbundle by name" --> I get 16 double array wires. I could build a 2D array from these, tunel it into the for loop, and I can write data to each of these in the for loop.

After this, I have to index out the 16 arrays from the new 2D array, and wire these 16 wires to the sinks of the Bundle by name.

 

I would like to avoid the above effort...


I'm not sure there's a better solution - although admittedly I'm not the most knowledgeable person in the forum.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 8
(3,852 Views)

The LabVIEW complier is highly optimized to make for loop operations on arrays very efficient.

 

Please show your code so that we can see exactly what you are doing.  Perhaps someone can offer suggestions for improvement.

 

Lynn

0 Kudos
Message 5 of 8
(3,829 Views)
Solution
Accepted by Blokk

I don't know if this is necessarily easier, but if you change the typedef cluster so that it instead contains 16 clusters, and each cluster contains a single item which is a 1D array, then you will be able to use Cluster to Array and Array to Cluster, although you'll have to do one additional unbundle/bundle inside the for loop.

Message 6 of 8
(3,819 Views)

Or perhaps you might consider a simple 16 x N (2D) array.

Instead of bundle/ unbundle you would index(row)/ replace(row).  This though would allow easy indexing through loops.

0 Kudos
Message 7 of 8
(3,813 Views)

thanks! I did not know this trick. And the additional undundle/bundle in the for loop is not too much. The main advantage here is that, I can use the "cluster to array" function, so i can directly connect the i iteration in the for loop to the "replace element in array" or to any other array manipulation function...

 

The 2D array approach would be also useful instead of the cluster. But I like the comfort what the cluster gives: any places in my code, when my cluster is filled with the data, I can easily "pick" any of the arrays with the "Unbundle by name"...

 

Thanks for the useful comments and advices,

regards!

Message 8 of 8
(3,798 Views)