LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to efficiently build 2d array from 1d array generated within while loop

Hello,

 

I'm fairly new to LabVIEW and was hoping to get suggestions on the most efficient way to build a 2d array from 1d arrays that change with every loop iteration. In the code I've attached the output of the cross-correlation function gives me a 1d array which currently contain 512 elements. At the end of the loop I would like to have a 2d array which would be (# of iterations) x 512 elements in size. The data files I'm dealing with are relatively large ( > 1 GB ) so minimizing computation time is neccesary as there eventually will be upwards of millions of iterations.

 

I originally took the approach of preallocating an empty array of zeros using the Initialize Array VI. From looking at the indicator it seems that it preallocates correctly (here shown as 100 x 512 element array). I then try and use the Insert into Array VI to insert the array generated that iteration into the next index. Now my problems begin when I look at the output array. The first thing I notice is that the array size has been dynamically changed from my preallocated array of 100 x 512 to the output array of 202 x  512. I imagine this is linked to the way I am indexing/initializing the array as the first 100 rows seem to be correct but the last 102 are filled with zeros. I could simply just delete the superflouous elements but that's hackish and not what I'm hoping to acheive. I understand that this issue may have been posted before but I couldn't find anything that would help in the exact manner I was hoping. Any suggestions on what I may be doing wrong or tips to improve efficiency are greatly appreciated.

 

Thanks!

 

Nolan

0 Kudos
Message 1 of 3
(2,920 Views)

It looks like you want to use the "Replace Array Subset" function instead of "Insert Into Array". 

0 Kudos
Message 2 of 3
(2,914 Views)

Ah now I feel silly, it seems to work just fine. Thanks for that. Do you think this the best way to build the 2d array with respect to computation time? That was the only other question I had.

 

 

0 Kudos
Message 3 of 3
(2,911 Views)