LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

concatenate the data from 2 arrays into a third array just like in concatenate strings

Solved!
Go to solution

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?

 

0 Kudos
Message 1 of 10
(3,099 Views)

The interleave 1D arrays primitive from the array palette does just that.

 

Clipboard01.png

 

Enjoy!


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 10
(3,095 Views)
Solution
Accepted by anarki

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...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 10
(3,094 Views)

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

Antoine Chalons

0 Kudos
Message 4 of 10
(3,088 Views)

that seems to do the trick. thanks

0 Kudos
Message 5 of 10
(3,076 Views)

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...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 10
(3,065 Views)

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!

0 Kudos
Message 7 of 10
(2,875 Views)

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

 

 

 

 

 

0 Kudos
Message 8 of 10
(2,870 Views)

@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. 

0 Kudos
Message 9 of 10
(2,849 Views)

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.

0 Kudos
Message 10 of 10
(2,837 Views)