LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding consecutive repeating numbers in binary array (or boolean)

Solved!
Go to solution

@simmertime wrote:

The input is a digital waveform of size 496 (1D).



A digital waveform can have several signals. Can you give a more specific example? Are you using the tools from the digital conversion palette? (would give a 2D boolean array or a numeric array with multiple bits/value).

 

My code above can easily do exactly what you need.

 

  • output the number of TRUEs if there is exactly one consecutive stretch of TRUEs (Count: 1..N)
  • output 0 if no TRUE exists. (same as "none found")
  • output -1 of more than one group of TRUEs exist. (same as "error")

 

 

 

 

 

0 Kudos
Message 11 of 18
(459 Views)

@simmertime wrote:

The input is a digital waveform of size 496 (1D). I convert it to a boolean array(T/F) and binary array(0/1) for other reasons. From the input I want to count how many ones are sandwiched between zeros, but if there are more than 1 sandwich I want to have a string indicator that there is an error. If there are no 1's found, I would like the string indicator to say none found. 

000111111000 Count= 6

0001110000111100 "Error"

000000000000 "None found" 


There are a few more cases to define.

 

1111100000 or 0000011111 no leading / trailing 0 1s length indeterminate?

0000111111100111 or 1100001111110000 one sandwich and an incomplete pattern?


"Should be" isn't "Is" -Jay
0 Kudos
Message 12 of 18
(446 Views)

If a 1 is at the start or the end that is an error. I would call it "incomplete data" regardless if it is 1110000 or 11000111000 (doesn't matter if it is the only chunk)

0 Kudos
Message 13 of 18
(427 Views)

Can you include this vi or list the components used? I'm having a hard time identifying them. 

0 Kudos
Message 14 of 18
(416 Views)

@simmertime wrote:

Can you include this vi or list the components used? I'm having a hard time identifying them. 


This is a long thread. Are you replying to any particular message? In that case you should quote some of it (as I just did right here above) so we know what you are referring to.

0 Kudos
Message 15 of 18
(405 Views)
Solution
Accepted by topic author simmertime

Here's my VI from the picture above. You might have trouble finding the "search array" because it has changed to a malleable tool (different color, more functionality)  in recent versions.

 

 

0 Kudos
Message 16 of 18
(401 Views)

To wrap this up, here's how it can be simplified if we only want the simple nonzero count and -1 otherwise.

(You can add the "OR Sum=0" back if you want to output zero if the array is all FALSE)


- Output the count of TRUEs if there is exactly one consecutive stretch flanked by FALSE
- Output -1 if
     - There is more than one stretch of TRUEs
     - All elements are FALSE
     - The input starts or ends with a TRUE

 

altenbach_0-1660232091638.png

 

0 Kudos
Message 17 of 18
(387 Views)

Hi altenbach,

 

I liked that the output could be -1 (invalid), 0 (no 1's found), or the sum. I added a few things to search if 1 is found in the beginning and the end and output an error (just an index array for the first and last, then OR those together). Thanks for your help!

0 Kudos
Message 18 of 18
(379 Views)