LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficiency when accessing arrays

I would like to access every element of a small 1D array (10 elements) and perform different operations on each element.  Is it more efficient to use an Index Array for every element or to change the array to a cluster and unbundle the cluster. If both of these sound like bad methods to you, what would be the best way of doing this?

Thanks
0 Kudos
Message 1 of 4
(3,113 Views)
You may not even need to index the array. 
 
Can you describe what the different operations are?  For instance, if the "different operations" are to be performed to each element, you may be able to do them directly.  Many VI's are polymorphic and are capable of handling arrays directly.  The catch is that they perform the same operation to all array elements at once.
 
Since you already have an array, it is not necessary to use a cluster.
 
Can you describe what you wish to achieve?
 
RayR
0 Kudos
Message 2 of 4
(3,103 Views)
Another possibility would be to use an autoindexing FOR loop. Place a case structure inside and wire the case terminal to [i]. Create a case for each of the "different" operations and assign each to the desired indices.
 
Please give a more specific example of what you actually need to do. I am sure there is a simple solution.
 
If course the question is how different are the operations? If the are "similar" (e.g. multiply vs. divide), you can operate on the array directly. For example if you have an array [1,2,3,4] and want to multiply the first two elements by 100 and divide the last two elements by 2, you could just multiply the array with an array constant of [100, 100, 0.5, 0.5].
 
Converting an array to a cluster just to get the elements is very silly and will make you eligible for an honorary Rube Goldberg award :). Why jump through flaming hoops just to get array elements?? All you need is to resize "index array" to give you 10 terminals. If you want the elements in order starting with element 0 you don't even need to wire any indices.

Message Edited by altenbach on 05-27-2007 08:56 AM

0 Kudos
Message 3 of 4
(3,098 Views)
Thanks for the replies, I am comparing array elements to each other after some arithmatic.  I am currently using a  auto indexed for loop with a case structure.   I guess Ill stick with that.

Thanks for the advice.



Come To the 15th IGVC challenge at Oakland U in Michigan.
Go to www.igvc.org for more info.
0 Kudos
Message 4 of 4
(3,092 Views)