04-04-2015 09:16 AM
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
04-04-2015 10:15 AM
04-04-2015 12:06 PM - edited 04-04-2015 12:13 PM
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.
04-04-2015 01:36 PM
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).
04-05-2015 04:38 AM
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
04-05-2015 10:56 AM
@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.
04-06-2015 12:17 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord