LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search in 1D array for a specific array

Solved!
Go to solution

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 consist
0 Kudos
Message 1 of 4
(3,824 Views)

You could convert the array with N elements to a string with N characters, then use string searching (pattern, regular expression). 😉

0 Kudos
Message 2 of 4
(3,817 Views)
Solution
Accepted by topic author ethen99

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.

Omar
Message 3 of 4
(3,811 Views)

woow..

Great solutions.

Many thanks for your quick reply.

0 Kudos
Message 4 of 4
(3,780 Views)