09-05-2013 10:37 AM
Hello, I've spent half a day to efficiently solve this simple problem, but unsuccessfully... Maybe you can point to the right direction..
I've for loop that generates two arrays .. Each usually contains couple of hundred elements.... I want to stick these arrays to gather in long 2D array as in attached figure.
Solved! Go to Solution.
09-05-2013 10:40 AM
Just use Build Array. You may need to use Transpose 2D Array to get the array the way you want it.
09-05-2013 10:51 AM - edited 09-05-2013 10:52 AM
09-05-2013 11:46 AM
Why not just use Insert Into Array?
If you want things to be horizontal like you wrote, use the transpose array functions. If you don't mind using things rotated 90 deg, just leave them out.
Cameron
09-05-2013 12:39 PM - edited 09-05-2013 12:52 PM
@camerond wrote:
Why not just use Insert Into Array?
Did you even look at his image and read the description? He want to sequentially fill an initialize large array with new data. The input arrays are also 1D, not 2D.
In your example, it would also be more typical to use "build array (concatenate mode)" instead of "insert into array" (middle).
Even simpler, use a FOR loop and avoid all these transpositions (bottom):
Still, this code does NOT solve the original problem of this thread!!!
09-05-2013 01:05 PM
Whoops. Yes I did, but I'll blame it on my glasses because I thought he had a 2-D array inside the FOR loop, as an example of what he was trying to combine. His initialization of a 2-D array at the front and an output array which had two copies of both input arrays (would have been adding a copy of the 2-D array inside, if it were there) seemed to support that conclusion, too.
Sorry, I'll be going back to the optometrist next week.
Cameron
09-05-2013 01:27 PM
Cameron,
Too many aromatic rings!
Lynn
09-06-2013 05:53 AM
I'm just wondering, why my VI gives an error.. Is it because of version 8.6 or ?
If I remove the first index it work fine.
09-06-2013 06:40 AM
You should only wire something to 1 of the index terminals (because you are putting an array into a 2D array) (had it been a single number into a 2D Array, you should have wired both index terminals)
If you wire to the first index terminal, it pops data into your 2D array row wise
if you use the second index terminal, it places it column wise
09-06-2013 06:42 AM
Since you are preallocating your array, I think you want to use Replace Array Subset instead of Insert Into Array.