LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove zero in an array and append elements

HI,

I am contiously generate data and I would like to check the bit 17 and then if it is true add 1 to an array and if not zero, then I would like to remove all zeros and just have ones out of the while loop ( when the user click on stop)

could you please help me on this. I have attached the vi

Thanks

 

 

0 Kudos
Message 1 of 9
(3,901 Views)

Can you upload your VI in 2011

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 9
(3,899 Views)

I attached the 2011 version to this email

0 Kudos
Message 3 of 9
(3,876 Views)

The VI you have attached does not have much resemblance to your question. Also, your diagram constant is empty, so we don't really know what typical data looks like.

 

Have you even wondered what would happen if you remove the "equal true" and wire directly to the select node? Same thing!

 

Please fill the diagram constant with some typical data so we can see what you have.

 

Counting is also typically done with integers, not floating point numbers. All you get out of the while loop is the array data from the last iteration. Is this really what you want?


tintin_99 wrote:

I am contiously generate data and I would like to check the bit 17 and then if it is true add 1 to an array and if not zero, then I would like to remove all zeros and just have ones out of the while loop ( when the user click on stop)

could you please help me on this. I have attached the vi


You seem to check bits at all multiple positions of 17. If you only want to retain the ones, you seem to generate a lot of redundancy and unnecessary intermediary data. All you need is count the "ones" in a scalar shift register and at the end initialze an array of ones of that size. Right?

So please attach a VI that contains typical data. Also tell us what result you expect from it. Thanks!

0 Kudos
Message 4 of 9
(3,868 Views)

Hi Tintin_99,

 

Check the attached vi. It does pretty much what you want to do. I have briefly explained the functionality on the block diagram.

 

Also, if you just need the number of 1's in the array, consider implementing what Christian has mentioned above. "All you need is count the "ones" in a scalar shift register and at the end initialze an array of ones of that size."


regards,
Nitz

(Kudos are always welcome, Mark it as a Solution if your problem is Solved;))

0 Kudos
Message 5 of 9
(3,854 Views)

Here's what I had in mind.

 

It is usually much more efficient not to create green arrays, but do bitwise operations directly on the integer. If we right-shift the number by 17 placed and bitwise AND it with 1, we get a 0 or 1, depending on the original bit 17.

 

Download All
Message 6 of 9
(3,849 Views)

Hi Christian,

 

This looks really good.:) One question, what if its a 64 bit data instead of 32 bit? I believe the bit wise shift works only for 32 bits and in this case, it has to be handled with multiple shift functions after splitting the data appropriately. Would you still prefer the bitwise shift to the green arrays in such cases?

 

regards,
Nitz

0 Kudos
Message 7 of 9
(3,839 Views)

bitwise shift works equally with U64 data. Do you have evidence that it does not?

 

Message 8 of 9
(3,833 Views)

I'm sorry Christian, I misinterpretted something and had a notion that the logical shift doesn't work for U64 shift. I just tested it now, it works perfectly fine with U64 data as well. Sorry again for the post and thank you for replying. 


regards,
Nitz

0 Kudos
Message 9 of 9
(3,828 Views)