08-18-2022 04:51 AM
I have an array of bistreams padded with random number of 0s at the beginning and end of the array.
array 1 = 0 0 0 0 ... 1 1 1 1 0 0 0 0 ..... 0 0 0 0 0
I need to remove these 0s at the beginning and end of the bitstreams. Since I do not know the number of 0s padded at the beginning and end of the array, I cannot directly use array subset.
But, I know that 11110000 is the start of the information I need within array1. So my array2 = 1 1 1 1 0 0 0 0. Now I need to search for array2 within array1 and get the starting point index. How do I search for a subarray bitstream within an array of bitstream?
Solved! Go to Solution.
08-18-2022 06:20 AM
Hi wannabe,
again you forgot to define the datatype of your "bitstreams"…
@labview_wannabe wrote:
But, I know that 11110000 is the start of the information I need within array1. So my array2 = 1 1 1 1 0 0 0 0. Now I need to search for array2 within array1 and get the starting point index. How do I search for a subarray bitstream within an array of bitstream?
repeat
Search for "1"
Check if you found the "1111.0000" start marker
until "marker found"
08-18-2022 06:23 AM
Hi GerdW,
sorry. So the each bit in the bitstream is U8 data type. So each bit is a U8.
Warm Regards
08-18-2022 06:52 AM
08-18-2022 08:39 AM - edited 08-18-2022 08:40 AM
@GerdW wrote:
Hi wannabe,
ok, this simplifies the implementation.
See my pseudocode above, you need
- (while) loop
- shift register for the current search position
- Search1DArray
- ArraySubset with a comparison afterwards…
Thanks GerdW. I used your method to search for 1 but I didn't use while loop. Hope this helps for someone else.
08-18-2022 09:26 AM
Hi wannabe,
@labview_wannabe wrote:
I used your method to search for 1 but I didn't use while loop. Hope this helps for someone else.