LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to search for array in another array ?

i want to search for array in another and when i got this array i want to take the next 5 bits  EX: array1 [ 4 8 7] , array2 [ 9 1 4 8 7 6 3 2 ] , output array [ 6 3 2 9 1]

Thanks  

0 Kudos
Message 1 of 7
(5,048 Views)
What have you already tried? Show us your code. This is not a difficult problem using the array functions, a for loop, and the equals function set to compare aggregates (right click to set the comparison mode). In particular, the split array (or array subset) and rotate array functions will be helpful.
0 Kudos
Message 2 of 7
(5,030 Views)

What is the size of your input array? Is it 2D array or 1D array? Your question isn't clear. If you have a 1D array then clearly you're quote " an array inside an array" isn't applicable since a column or row matrix (1D array in labVIEW) cannot have an another array of some dimension inside.
If it is a 1D array, what you are asking is a range of elements to be fetched out and then building them up in an array. This is what I could understand.

You have this,

 

[ 1 2 3 4 5 6 7 8 9 0]

 

and you want this

 

[1 2 3 4]

 

This means you need only the first four elements from the input array. Which in labVIEW means from index 0 to 3. Use FOR LOOP with iterations equal to the number of elements you want to fetch, an "index array function" and then "build array". Run and say eureka!! when you're done.

If you want to search for specific elements, then use the above technique along with some "compare" function and probably with a "case structure". If compare node gives true, add the value inside an array or else add nothing (simply wire the input to the outpure node in false case). Also you will need to add a shif register.

 

Regards.


0 Kudos
Message 3 of 7
(4,995 Views)

What is the datatype of the array? If it is U8, you can cast to strings and use the string functions for searching.

 

Can you explain what you mean by "bits"? That does not make any sense in this context. Do you mean to take the next five array elements (i.e. bytes in the case of U8).

Message 4 of 7
(4,973 Views)

I send signal of 40 samples to USRP and recieved it and put it into array , i want to search in this array for 8 bits [ 1 - 1 1  -1 1 -1 1 -1] so when i get this array i want to return the other 32 samples in array , it's a 1D array, example : inputarray [ 2 4 6 8 1 3 7 9 ] , arraysearch [ 6 8 1] , outputarray [ 3 7 9 2 4 6] ,,,,,another example :input array  [ 1 3 7 9 2 4 6 8 ]    arraysearch [ 6 8 1] , outputarray [ 3 7 9 2 4 6] , the input array i received will change because i received the signal several times and i stop in any time 

0 Kudos
Message 5 of 7
(4,906 Views)

@hussamwakeel wrote:

I send signal of 40 samples to USRP and recieved it and put it into array , i want to search in this array for 8 bits [ 1 - 1 1  -1 1 -1 1 -1] so when i get this array i want to return the other 32 samples in array , it's a 1D array, example : inputarray [ 2 4 6 8 1 3 7 9 ] , arraysearch [ 6 8 1] , outputarray [ 3 7 9 2 4 6] ,,,,,another example :input array  [ 1 3 7 9 2 4 6 8 ]    arraysearch [ 6 8 1] , outputarray [ 3 7 9 2 4 6] , the input array i received will change because i received the signal several times and i stop in any time 


You still have not answered my question about the datatype of the array.

Bits cannot be negative, please explain. Does -1 mean the bit is not set?

How are bit represented in your data?

 

Please attach a small VI that has a typical input array and an example for the seach term as default data in the controls. Then tell us the expected result.

0 Kudos
Message 6 of 7
(4,865 Views)

I know we should be encouraging others to help them selves, but I had a solution that I think is what the user wants.  Attached is a VI that searches for a subarray in an array, and will return the index it is found at.  It will also return the input array, filtered if a match is found.  This VI just handles the double data type.

 

Most of the code comes from an old post by Altenbach that I can't seem to find at the moment, but I saved a copy a while ago.  Props to him for posting it.

0 Kudos
Message 7 of 7
(4,802 Views)