LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert a 2D array into a 2D array starting at a specific index

Solved!
Go to solution

Hi,

Is it possible to insert a 2D array into another 2D array, starting at a particular index.

For example, I have a 2D array of 4X100

Now, I want to insert a 2X50 array into index row 3 and column 50.

If there are already elements from [3,50] to [3,100], and from [4,50] to [4,100], I'd like to replace those element by the new 2X50 array.

 

Is there a way to achieve that without doing 1 by 1 element?  

 

Thank you!

 

Best,

Charles

0 Kudos
Message 1 of 4
(3,652 Views)

Use replace array subset. If you wire both indices, it allows you to replace a 2D section into an existing 2D array.

 

Of course you need to do some math in case the final array needs to be bigger than the existing array to accomodate both. In this case you would initialize a new, larger 2D array with some padding element (e.g. NaN), then replace array 1 at 0,0 and the second array at the desired index.

0 Kudos
Message 2 of 4
(3,651 Views)
Solution
Accepted by topic author soljiang

altenbach wrote:

Of course you need to do some math in case the final array needs to be bigger than the existing array to accomodate both. In this case you would initialize a new, larger 2D array with some padding element (e.g. NaN), then replace array 1 at 0,0 and the second array at the desired index.


Here's a general example assuming padding is needed. Probably needs a few tweaks. (I divided your number of rows by 10 to make it easier to see the outcome. Modify as needed).

 

Download All
Message 3 of 4
(3,643 Views)

Thank you!

0 Kudos
Message 4 of 4
(3,612 Views)