07-31-2013 06:20 AM
Hi!
Is there a VI or a simple way to search for a subarray in array and to get the index of the subarray? The same thing does DTbl Search for Digital Pattern.vi with digital data and Search 1D Array.vi searches for just one element in the array.
Thank you!
Solved! Go to Solution.
07-31-2013 06:27 AM
07-31-2013 06:44 AM - edited 07-31-2013 06:55 AM
Depending on your needs, something like this might suffice.
Using the Search 1D Array function will find the locations of the FIRST occurrence of every element in the subarray. (As demonstrated with the number "1" in the example below)
If the element cannot be found, it returns a -1. (As demonstrated with the number "9" in the example below).
You can check this each iteration for error checking. (Or search the output array for -1 using the same Search 1D Array function).
**Note: Also remember that arrays are 0 indexed! 😄
07-31-2013 07:38 AM - edited 07-31-2013 07:39 AM
Playing around with Gerd's idea of using the search 1D Array, I came up with this.
08-01-2013 03:18 AM
I tried to play around Gerd’s idea as well but your solution looks much better! Thanx!