11-16-2012 10:45 PM
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
Solved! Go to Solution.
11-16-2012 11:00 PM
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.
11-16-2012 11:37 PM - edited 11-16-2012 11:37 PM
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).
11-18-2012 04:30 PM
Thank you!