LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find the counts of consecutive 0s and 1s

Solved!
Go to solution

The file includes IQ readings. These readings are converted into RMS power. various algorithms are applied to extract noise from signal. After all analysis stages a boolean array is generated (0s and 1s).

0 Kudos
Message 31 of 38
(1,704 Views)

Hi James.Morris.. I tested and evaluated all given solutions after employing them in the main project. I just reported what I got and what I will try to do. Thanks

0 Kudos
Message 32 of 38
(1,703 Views)

@walidbalid wrote:

The file includes IQ readings. These readings are converted into RMS power. various algorithms are applied to extract noise from signal. After all analysis stages a boolean array is generated (0s and 1s).


So, counting the final booleans seems like a very minor part of the process. How are you doing the first parts? How efficient is that?

 

Where and how is the boolean(0,1) array stored? You still haven't defined your use of the term "large". can you give some numbers?

 

A boolean takes up very little space, properly done you can even store 8 in a single byte if memory is tight.

0 Kudos
Message 33 of 38
(1,687 Views)
Solution
Accepted by topic author walidbalid

On a side note, here's my code operating on an U8 array of zeroes and ones. It is important to operate in place and not convert large datasets to different representations.

 

 

There is still some ambiguitiy in the output, because from the two arrays we cannot tell if the original array started with false of true (except if one of the arrays is larger by one).

 

What else will be done with the output? Is having two arrays really the most convenient? Another possibility would be to create a single output array and set the lenght of the trues as positive counts and the Falses as negative counts. (e.g. [1,1,1,0,0,1,0,0,0,1] would give a single I32 array of [3, -2, 1, -3, 1]).

 

The code could also be made more efficient if you have a good guess on the size of the output array. Do you?

Message 34 of 38
(1,665 Views)

altenbach wrote:

The code could also be made more efficient if you have a good guess on the size of the output array. Do you?


The thought I was having is you could use a FOR loop to run N/2 times and stop it like you do now.  I think N/2 would be the max size of each (assumes each element is a change).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 35 of 38
(1,533 Views)

Here is a version using a state machine  driven by the boolean array. At ten million iterations of the array generator Bob Schor posted this is about 3.5 times faster than Bob's code.  I did not compare it to altenbach's or crossrulz's code.

 

The Boolean Array Constant.vi just contains Bob's constant array for testing.

 

In a preliminary version I had indicators on the count arrays and the boolean array to verify that it worked correctly. That is why I had to add a bit of code to capture the last block.

 

Lynn

Download All
0 Kudos
Message 36 of 38
(1,473 Views)

Lynn, I think you need to be very careful here. Since your boolean array enters the second frame from the top (i.e. skipping the first frame), the first frame can run in parallel withe the data generation, falsifying the start time. You need to wire the boolean array across the first frame to make the result meaningful.

 

Once you wire the array across the first frame, Bob's code is actually faster. 😄 (And some casual testing show my code even faster :D)

0 Kudos
Message 37 of 38
(1,463 Views)

Thanks.  I had some inconsistent behavior that may be explained by that.

 

Lynn

0 Kudos
Message 38 of 38
(1,367 Views)