LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

evaluate cluster elements - write to array

Solved!
Go to solution

I have a cluster with a n boolean values that correspond to columns of an array.  I need to read the values each boolean and if true write the corresponding column to an output array.

 

I am having difficulty in figuring out to do this.  

 

I have attached an example the demonstrates what I am trying to do.   Please let me know if what I am trying to do is possible and how I would modify the code to do this.

 

Thanks for the help.

0 Kudos
Message 1 of 5
(3,575 Views)
Solution
Accepted by topic author fvnktion

You're not using the right tool for the job. Why don't you use an array instead of a cluster? 😮

 

If all elements in a cluster have the same type, you can easily convert your cluster to an array for easy indexing at the loop boundary.

 

I have no idea why you are using a sequence structure. It has no function here. Just use dataflow.

 

Here's a quick draft on how you could do things. Modify as needed.

 

Message Edited by altenbach on 12-20-2008 01:17 PM
Download All
Message 2 of 5
(3,564 Views)

Note that the above "simple" solution is OK for small arrays. If you are dealing with very large datasets, it will not be very optimized for memory efficiency because each "transpose" operation and each "built array" operation requires a new buffer allocation.

 

Ideally, you want to operate "in place" as much as possible. Here's a quick draft how this could be done. See if it makes sense. Now all operations are carried out in the original 2D array and at the end the excess is trimmed on one step.

 

 

Message Edited by altenbach on 12-20-2008 01:41 PM
Download All
Message 3 of 5
(3,559 Views)

altenbach,

 

You're the best.  Thanks for the solution and the better solution.  I havn't been able to fully analyze them yet, but this makes perfect sense.

 

As you see I am just getting into the labview realm and trying to make sense of all of it.  Your help is invaluable.

 

Thanks 🙂 

0 Kudos
Message 4 of 5
(3,552 Views)

If most booleans are true, you could further improve the second solution by only doing a "read...replace" if the two indices actually differ.

 

We only need to start touching columns at a TRUE after the first FALSE  was encountered. Before that, we are currently just writing the same data back to where it already was. If the first FALSE comes typically early, it won't make much of a difference.

 

Probably not worth the extra code. 😉

Message 5 of 5
(3,543 Views)