LabVIEW Real-Time Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
gmr2017

Array Subset Using Array of Indexes

Status: New

We have large arrays in our applications and normally we want a subset of data that is not contiguous. To accomplish the task of retrieving values of various indexes we use a For Loop feeding in an array of indexes. We obtain a single value in each iteration of the array. Not very efficient!

 

Index Array is expandable at design time but we don't know how many values we need at design time.

 

It would be ideal if there was a native LabVIEW function that accepted an array of indexes and returned an array of values from a much larger array. Similar to the Array Subset function but the index input is an array of values not just a single value.

1 Comment
Mads
Active Participant

Picking values from an array like this is already extremely fast even if it is done one element at a time. If you have a speed issue with it I would expect the issue to be in a lack of preallocating memory and use of build instead of replace.

You could make a wrapper that analyzed the required segments and extracted continous sub-sections of the array using Array subset instead of index array, but the overhead of that would most likely be higher than just the indexing....The speed hit is almost always by having to rescale arrays continously. Whether this occurs in the actual extraction of the indexes here or in how you generate the array of indexes instead e.g. (as I would expect the former to then occur in a for loop (?) which would preallocate the result for you already) I do not know...but the actual indexing itself as a speed issue? If that is the case the time requirements must really be super-tight...

PS. This should probably be moved to the general LabVIEW forum as such a primitive would apply to all targets, not just RT.