12-19-2011 12:19 PM
Hi
I have a 1D array list consists of series of 1 and 0. Consider the size of this data array is 1000
Now I would like to search in this array for a specific pattern like 00110101 or any random sequence . So there might be more than 1 match in the 1D array
and I would like to get the index of first element for all matches.
Would you please help me with this code. Firstly how can I search for an array not just one element ( Not search1D array.vi) and also how can I get the index for that match
Many thanks
I have a data array consistSolved! Go to Solution.
12-19-2011 12:58 PM
You could convert the array with N elements to a string with N characters, then use string searching (pattern, regular expression). 😉
12-19-2011 01:15 PM
Brute Force
For loop (no auto indexing)
Inside for loop get Array Subset one index at a time length set to length of search pattern.
Does array subset equal pattern? If true for loop iteration is the array index of matching.
Repeat until end of array - pattern length + 1 times.
Try it and post your code.
12-20-2011 08:19 AM
woow..
Great solutions.
Many thanks for your quick reply.