12-20-2008 02:09 PM
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.
Solved! Go to Solution.
12-20-2008 03:16 PM - edited 12-20-2008 03:17 PM
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.
12-20-2008 03:40 PM - edited 12-20-2008 03:41 PM
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.
12-20-2008 04:03 PM
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 🙂
12-20-2008 04:25 PM
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. 😉