LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find a value in a boolean array


@altenbach wrote:

 

The sentence "find the only one that is true" implies that there is exactly one that is true, so finding it implies getting its index. We already know the value and that it xists exactly once.

 

The only complication would be in the case of higher dimensions, but he only gave a single number of elements, so it is probably 1D.


That might be true.  (Ha ha, see what I did there)

 

But how often do people on the forum make a suggestion with what is implied or assumed only to find out they were wrong? 

0 Kudos
Message 11 of 25
(3,259 Views)

@Neil_Helsel wrote:
I'm sorry it's a 2D array.

 

Ok wire the 2D boolean array directly to "boolean to 0,1" followed by "Array min&max". Then get the index of the max (second output from the top). The index is a 1D array with two elements and indicates the location of the TRUE in the 2D array.

 

If your array is aready numeric (0, or 1), yo can skip the first step.

Message 12 of 25
(3,250 Views)

It doesn't seem to want to wire to that. I'll include my code and another forum link to preface what the DAQmx is for. I'm sorry I'm new to LabVIEW and am not too familiar with it yet.

 

Background on the code

Download All
0 Kudos
Message 13 of 25
(3,226 Views)

I don't see any arrays in the code you attached  above. I guess we need more information.

0 Kudos
Message 14 of 25
(3,201 Views)

In Test 1(2) the Digital 1D Wfm looks like it sends out a boolean array.

0 Kudos
Message 15 of 25
(3,183 Views)

@Neil_Helsel wrote:

In Test 1(2) the Digital 1D Wfm looks like it sends out a boolean array.


Why do you attach two similarly named VIs with identical size. How do we know where to look?

 

You have a 1D array of digital waveforms. This has nothing to do with a 1D or 2D boolean array. However you could easily convert to a 2D boolean array, especially of all digital waveflorms have the same lenght (do they?). Use a simple autoidenxing FOR loop. See how far you get.

0 Kudos
Message 16 of 25
(3,181 Views)

Okay gotcha. So with my 1D array of digital waveforms I have my index on the left column and T/F on the right. I'm trying to use search 1D array to find where it's T. I don't really understand how to use 1D array of digital waveforms constants though to make this happen.

 

Any tips on that?

0 Kudos
Message 17 of 25
(3,166 Views)

@Neil_Helsel wrote:

Any tips on that?


You can always convert it to a boolean array and the use our earlier advice. Here's one possible solution using this function😞

 

 

(Sorry, I never use dynamic or waveform data. Maybe you could even configure your DAQ IO to output  boolean arrays directly. (I don't have DAQmx installed, so I cannot tell).

0 Kudos
Message 18 of 25
(3,153 Views)

Are there any array functions that work with 1D arrays of digital waveforms, because non seem to like being wired to the 1D array of digital waveforms?

0 Kudos
Message 19 of 25
(3,128 Views)

What's wrong with the FOR loop in my example?

 

(true we get too many dimension, but I cannot check what's actually happening.)

0 Kudos
Message 20 of 25
(3,124 Views)