Modelica arrays with unspecified dimension

柔情痞子 提交于 2019-12-11 03:19:03

问题


Given a model with an array x of connectors where its size is unspecified, e.g.

connector con
...
end con;

model test
con x[:];
end test;

How can x be instantiated with a specific size, e.g. something like this?

test t(x = ?);
...
equation
connect(t.x[1], a);
connect(t.x[2], b);
...

回答1:


Why do you need unspecified dimension? You can do something like this:

connector con
...
end con;

model test
 constant Integer dim = 1;
 con x[dim];
end test;

// usage
test(dim = 10);
...
equation
  connect(t.x[1], a);
  connect(t.x[2], b);
...


来源:https://stackoverflow.com/questions/29187792/modelica-arrays-with-unspecified-dimension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!