LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert 2D array into an existing 2D array

I have a 2D array ( read from file )which I would like to insert into an existing 2D array (read from file).  Both arrays contain the same number of rows but the number of columns vary. Any suggestions?
0 Kudos
Message 1 of 10
(3,522 Views)
Hello cif,

suggestion: make the number of columns the same 🙂
Add empty columns to the smaller array.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,509 Views)
you can use the 'Insert into array' primtive from the array function palette. I inserts new data into n-dimensional arrays, where the inserted part must be of the same dimension as the original array or one dimension less. So it increases the original array size just in one dimension.

Greetings from Germany!
--
Uwe

0 Kudos
Message 3 of 10
(3,507 Views)
Having the same amount of columns isn't practical as the small array contains 4 columns and the larger array 1078!
0 Kudos
Message 4 of 10
(3,506 Views)
Hello cif,

you should say what you want to have as resulting array.
You have to arrays (1st: 10*4 elements, 2nd: 10*1078 elements; 10 is number of rows and equal for both arrays, column number is different).
Should the result be an array of 20*1078 elements (inserted/appended using the 1st index) or an array of 10*1082 elements (inserted/appended using 2nd index)?
Or should the result be an array of 10*1078 elements by just replacing some elements in the bigger array?

You better tell clearly what you need!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 10
(3,494 Views)
Sorry for any confusion. The 1st array ( 2048 rows x 4 columns) should be inserted into the second array ( 2048 rows x 1078 columns) to produce an end result of an array ( 2048 rows x 1082 columns). Ideally, the 1st array values should precede those of the 2nd array.
 
Thank you
0 Kudos
Message 6 of 10
(3,490 Views)
Hello cif,

so you just want to append those arrays. That's not INSERTING !

See the example...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 10
(3,482 Views)
I tried to use the attached vi to append the data but the result is that the 1st array returns correctly but the 2nd array is just zeros. It is probably really trivial.
 
 
 
0 Kudos
Message 8 of 10
(3,474 Views)
Hello cif,

have you tried my example? Both output arrays do not contain only zeros...

In your example you do array manipulation in a for loop, but you don't use a shift register to hold your array! So LV always takes the original data in each iteration!
Secondly put all 'constant' operations outside of the loop (checking array sizes) and resize your 'IndexArray' operators to give more than one output...


Message Edited by GerdW on 05-05-2006 04:32 PM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 9 of 10
(3,468 Views)
Thank you for all of your patience. Your example works perfectly for thisSmiley Happy
0 Kudos
Message 10 of 10
(3,455 Views)