05-14-2013 12:29 PM
Hi. I have big chunk of 1 and 0 . I would like to replace a 0 for every greater than 5 number 0s , the same for 1s
like this.
if this is my input data: 000000111111110000001111111000 I would like to change it to 0101000
Could you please help me on this one and show me with a sample code How I can do it in LabVIEW. Many thanks
05-14-2013 12:46 PM
05-14-2013 12:53 PM
could you please attach the vi, also is ther any way to delete the 0s in the end ( because number of 0s is less than 5 )
so 11111100000111111000 should be changed to 101
Many thanks
05-14-2013 01:24 PM - edited 05-14-2013 01:34 PM
05-14-2013 01:33 PM
@altenbach wrote:
Here's a non-regex solution. 😄
Any advantages over the regex from Darin? Is it something to do with memory/speed/performance? Just curious.
05-14-2013 01:35 PM
You should benchmark it. Are the strings big enough that it actually matters?
05-14-2013 01:43 PM
@altenbach wrote:
Are the strings big enough that it actually matters?
Actually I wouldn't know. This is something only "tintin_99" would know. But I just saw Darin's example and looks simpler (code wise) than yours. So I'm thinking if regex has any shortfalls (in this case) compared with non-regex version.
Kas
05-14-2013 01:49 PM
@tintin_99 wrote:
could you please attach the vi, also is ther any way to delete the 0s in the end ( because number of 0s is less than 5 )
so 11111100000111111000 should be changed to 101
This is in direct contradiction of your first message, where the trailing tail was retained.
If you want this functionality, you can modify my last case structure on the right and delete the "initialize array" and make the output tunnel to "use default if unwired".
05-14-2013 01:58 PM
Many thanks altenbach. Is there any way to put a limit for the number 1s or 0s . So lets say if the number of 1s is less than 3 delete them . If it is more than 3 and less than 5 change it to a single 1
so for example the following series be encoded to:
110000(11111111111)000011 ----> 0 (1 1) 0
I am really sorry for asking a new question in every post
05-14-2013 02:01 PM - edited 05-14-2013 02:02 PM
@tintin_99 wrote:
Many thanks @altenbach. Is there any way to put a limit for the number 1s or 0s . So lets say if the number of 1s is less than 3 delete them . If it is more than 3 and less than 5 change it to a single 1
Yes, just modify the innermost case structure. for example you could make folliwng cases:
etc...