From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

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

Indexing Arrays by Content

I often want to pull elements out of an array based on their content. In a simple example, I'd like an array B that contains all, the elements of A that are greater than 0.5. A few previous posts have suggested a conditional append function on the output of a loop. Here's another possibility. Change IndexArray so that one can wire an array of Booleans to the Index input. The output would be just those elements of the input array for which the Boolean array element is true.

 

 

Another way to handle this would be to have a primitive that returns an integer array containing the indices of the true elements in a boolean array. Then allow arrays of indices to be wired to the Index input of IndexArray.

 

By the way, these are not really orignal ideas. They come from Matlab. Specifically, the A(A>0.5)  syntax and find(A>0.5).

5 Comments
SteveChandler
Trusted Enthusiast

Open G has those functions.

=====================
LabVIEW 2012


David_Ferster
Member

Yes, but  the OpenG implementation is likely to be a LOT slower than if they were native.

SteveChandler
Trusted Enthusiast
That is why I gave this a kudo. But if implemented it probably will not be in 2011. So Open G is the best we have for now.
=====================
LabVIEW 2012


tst
Knight of NI Knight of NI
Knight of NI

This is a duplicate of this (which actually has been mentioned in the comments to the original conditional-indexing idea) - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-booleans-for-array-indexing/idi-p/1309062

 

 


___________________
Try to take over the world!
G-Money
NI Employee (retired)