LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I search for a subarray of bitstreams within an array of bistreams?

Solved!
Go to solution

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?

0 Kudos
Message 1 of 6
(1,005 Views)

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"
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(973 Views)

Hi GerdW,

 

sorry. So the each bit in the bitstream is U8 data type. So each bit is a U8.

 

Warm Regards

0 Kudos
Message 3 of 6
(967 Views)
Solution
Accepted by topic author labview_wannabe

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…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(959 Views)
Solution
Accepted by topic author labview_wannabe

@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.

paddingremove.PNG

0 Kudos
Message 5 of 6
(922 Views)

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.

paddingremove.PNG


  • Please post real code next time instead of just an image of code…
  • Cleanup the code before posting!
  • You don't need to wire the length input of ArraySubset to get the "rest" of the array, and so you don't need all those calculations…
  • I prefer to have terminals not in "Show as Icon" view, but definitely hate to have a mixed set of terminals in small and icon view…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(908 Views)