LabVIEW Idea Exchange

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

There should be a way to index an array with an array of indexes or booleans (without a loop)

Hi, often I would love to index an array with an array of indexes or an array of booleans without having to loop it. I.e: let the IndexArray function accept an array of indexes instead of discrete indexes. The output should then be an array of indexes values. Another use case is to index with an array of booleans, so each TRUE element would index the input array and FALSE elements are not indexed.

 

arrResult = arrInput[ arrIndexes ]; or

arrResult = arrInput[ arrVal > 20 ];

 

Would this be useful? Possibly it could be implemented in future versions?

6 Comments
TomOrr0W
Member

So, basically you are looking for a native LabVIEW implementation of the OpenG Index Array Elements (http://wiki.openg.org/Index_Array_Elements) and OpenG Conditional Auto-Indexing Tunnel (http://wiki.openg.org/Conditional_Auto-Indexing_Tunnel).

donkdonk
Member
AnthonV
Active Participant

Yes exactly like Matlab - once you are used to having this feature you find that it is a pain not having it.  Note I am also very keen for the array-of-I32indexes idea which is different from the array-of-booleans idea.  It would be great if LabVIEW had this as an overloaded version of the index array function.

 

Enrico_Segre
Active Participant

I made myself a polymorfic VI for the cases I use more frequently:

 

Screenshot from 2012-07-20 19:18:49.png

donkdonk
Member

Duplicate Allow-booleans-for-array-indexing

 

This was suggested by me before the conditional terminal in a loop was introduced.

I now like the conditional terminal.

 

Another duplicate There-should-be-a-way-to-index-an-array-with-an-array-of-indexes

 

Somehow not easy to find when you don't know a keyword to look for, it took me some time Smiley Wink

Darren
Proven Zealot