LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make this in labview : find the numbers of overlapping between bits

Solved!
Go to solution

Dear

I have this problem it really so complex to solve for me

its not home work its related to my academic research


I have two stream of bits each one with fixed n bits length as follow:

x=1,1,1,1,0,0,0,0

y=1,1,1,0,0,0,0,0

I need to extract the following information

a1, the number of overlapping 1s:in this case is 3
a2, the number of overlapping 1s of X and 0s of Y :in this case is 1

a3, the number of overlapping 0s of X and 1s of Y:in this case is 0

a4, the number of overlapping 0s on both x,y.:in this case is 4

 

thank in advance

best regards

hi ?Q>

0 Kudos
Message 1 of 14
(3,555 Views)

Mangood,

I have assumed  the stream of bits as boolean array

so here is an idea

overlapping.png 

Message 2 of 14
(3,545 Views)
What is the datatype of these "streams" (boolean arrays, numeric arrays, etc.).

To get the matching bits (a1), do a logical AND of x and y. To get a2, negate x first, then do the same,

Etc.

We how far you get...
Message 3 of 14
(3,544 Views)

Altenbach is right, we need some clarification on data types. Even if they are numeric values, you can still do bitwise comparisons with the comparison functions. And, just FYI neos, this is a much simpler way to count the number of true booleans in an array:

 

 

Message 4 of 14
(3,531 Views)
Solution
Accepted by mangood

Sorry, I was posting by phone earlier. Here's what you can do.

 

 

 

(If the arrays are large, you need to convert to I32 before summing)

Message 5 of 14
(3,524 Views)

dears

thank you  to all
all  answers amazing but i will consider the last post as solution

kudos for all

 

hi ?Q>

0 Kudos
Message 6 of 14
(3,515 Views)

 

just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.

 

numeric.png

0 Kudos
Message 7 of 14
(3,506 Views)

just FYI neos, this is a much simpler way to count the number of true booleans in an array:

 

Yes Greg, for number of trues and numbers of false also ( if total array size - number of true ), i would not have thought of it myself for the first time. thanks.

Christian,

Now i think i am learning LabVIEW. I am thinking RUBE and you are getting it.

0 Kudos
Message 8 of 14
(3,469 Views)

 


@alexderjuengere wrote:

 

just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.

 




 

Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:

 

 

 

0 Kudos
Message 9 of 14
(3,429 Views)

@alexderjuengere wrote:

 

just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.


There are other serious limitations, for example if the count is more that 256, you're in trouble. 😄


@for(imstuck) wrote:

Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:


For the more general case of large packed binary arrays (e.g. 8 booleans/U8), my code can be re-used almost unchanged, except for the summation which would use a U8 lookup table to get the bit count per byte and sum those up.

0 Kudos
Message 10 of 14
(3,410 Views)