01-31-2013 08:59 AM
Hi. as the title says, i would like to concatenate the data from 2 arrays into a third array similar to what concatenate strings does. All arrays should be 1D. For example, assume there's Array 1 with the folowing elements: 1;2;3;4. And Array 2 with: a;b;c;d. I would like array 3 to be 1a;2b;3c;4d. Now this could be done easily with above mentioned concatenate strings, and then build array. but Array 1 and 2 have something like 150 elements. Pretty tedious. Any ideas?
Solved! Go to Solution.
01-31-2013 09:07 AM
The interleave 1D arrays primitive from the array palette does just that.
Enjoy!
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
01-31-2013 09:09 AM - edited 01-31-2013 09:13 AM
Take the two string arrays into a for loop, concatentate the strings inside the loop and run the result back out to array3.
Autoindexing handles the array manipulations.
MIke...
01-31-2013 09:13 AM
oops... ignore my post I missed half the comas in your wish for the 3rd array, mikeporter is right, a concatenate string inside a for loop will do it.
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
01-31-2013 09:37 AM
that seems to do the trick. thanks
01-31-2013 09:57 AM
Autoindexing is a very powerful capability. In addition, if the arrays are potentially large or the string of varying length, you might also want to look into "Iteration Parallelism".
Mike...
09-16-2014 11:24 AM
What if your program is very time sensitive (due to hardware) and you've got a ton of data? Isn't there another possible way to merge two arrays into 1 without looping? All I'm really trying to do here is pad (string formatted) data with zeros.
Thanks, in advance!
09-16-2014 11:39 AM
Please, disregard for now. I went further back in my program and think that I may be able to change the formatting when the data is retrieved: %06x
09-16-2014 01:51 PM
@Adam.Kuhlman wrote:
Isn't there another possible way to merge two arrays into 1 without looping?
Whayt makes you think that "looping" impacts performance?
Show us exactly what you have and what you want and we will be able to suggest alternatives.
09-16-2014 02:13 PM
Thank you for your offering, altenbach, but I realized a better solution for me was to change the formatting and pad with zeros. In my case, the "looping" would have occured during FPGA data transmitting/receiving and I'm already strectched for time.