[英]Modelica: add a row and column in 2d array
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
. 我在模型中有一个计算值的二维数组(例如z),并希望使用MSL的CombiTable2D对
xi
和yi
给定值进行插值。 The CombiTable2D documentation suggests that the first row and column needs to be x0, x1, .. xi, ..xn
and y1, y2, .. yi, ..yn
. CombiTable2D文档建议第一行和第一列需要为
x0, x1, .. xi, ..xn
和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: 要使用CombiTable2D进行插值,数组必须采用以下形式:
[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. 因此,我想向现有数组添加行和列,以将其作为表格传递给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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.