LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting 1-D array into 2 arrays after every 16 samples?

I currently have a 1-D array(type string ( can direct it for type binary as well which is what i want)). I want to split the array into 2 arrays with the first 16 array samples going into the first array and the next 16 arrays samples going into the second array and so on. The problem here is that since i want to optimize the code for time issues i can't really work with shift registers to split the array. Also it would be great if i can combine the 16 array samples into an integer (since variables would be binary) while splitting the array itself.

Thanks.
0 Kudos
Message 1 of 6
(3,130 Views)
(It is probably a misconception that shift registers will slow you down. They are very fast. slow is only constant array resizing).

For your problem, just use "reshape array" after padding the input array to contain a multiple of 32 elements and make it into a X-by-32 array.
Feed this into an autoindexing "for loop" where you "split array" each 32 long chunk at position 16. Autoindex each of the two outputs at the loop exit, then reshape each back to a 1-D array.
0 Kudos
Message 2 of 6
(3,130 Views)
Does each string in the array represent an integer, and you want the first 16 integers in array 1, the next 16 in array 2, then the next 16 in array 1...etc?

If that's the case then the attached code might do the trick...just change the split every N number from 4 to 16...
Message 3 of 6
(3,130 Views)
Thanks for the prompt reply. The attachment helped out in reducing the array to 2 arrays of the type i needed. But I still have a problem in which i need to combine 16 elements of each array into one element without possibly using either concatenate string(probbaly not possible) or shift registers.
Attached is the file in which i have added my code to the code that you sent and in the diagram where it shows the shift register part that I could do without.
Thanks
0 Kudos
Message 4 of 6
(3,130 Views)
Do you have an example that could possibly illustrate this. My file is attached in the next answer on the segment I have highlighted the part where i do the combination of 16 elements to 1 element.

Also dosen't constant array resizing happen due to the fact that we use shift registers. I believe that everytime you use the shift registers especially in the case of an array shift register the whole value needs to get written to a new place in memory and that is why it takes much longer. Just wondering.
Thanks
0 Kudos
Message 5 of 6
(3,130 Views)
Shift registers do not allocate memory on each iteration, it works with the same block continously....shift registers are very very fast - so if the code is slow there is probably some other reason for it.

Unfortunately the uploaded file is 0K, something must have gone wrong during the upload. If you could upload it again I'll be happy to check it out:-)
0 Kudos
Message 6 of 6
(3,130 Views)