08-10-2022 11:06 AM
@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.
08-10-2022 01:58 PM
@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?
08-10-2022 02:05 PM
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)
08-11-2022 08:03 AM
Can you include this vi or list the components used? I'm having a hard time identifying them.
08-11-2022 09:27 AM
@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.
08-11-2022 09:33 AM
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.
08-11-2022 10:36 AM - edited 08-11-2022 11:19 AM
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
08-11-2022 10:39 AM
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!