I have a 2d array of calculated values (say z) in a Model and want to use CombiTable2D from MSL to interpolate for given values of xi
and yi
. The CombiTable2D documentation suggests that the first row and column needs to be x0, x1, .. xi, ..xn
and y1, y2, .. yi, ..yn
.
For example, if the array is:
[z11, z12;
z21, z22]
To interpolate using CombiTable2D the array has to be of the form:
[0, x1, x2;
y1, z11, z12;
y2, z21, z22]
Therefore I want to add a row and column to the existing array to pass it as a table to CombiTable2D. Does anyone have a suggestion?
You append to an array by putting the row (with ";") or column (with ",") and the array you want to append to inside square-brackets []. An example which solves your problem:
example = [1,2;2,3];
newRow = [1,2];
addRow = [newRow;example];
newCol = [0;1;2];
addCol = [newCol,addRow];
Output:
addRow =
[1, 2;
1, 2;
2, 3]
addCol =
[0, 1, 2;
1, 1, 2;
2, 2, 3]