首页 文章

具有未指定维度的Modelica数组

提问于
浏览
2

给定具有连接器阵列x的模型,其中未指定其尺寸,例如,

connector con
...
end con;

model test
con x[:];
end test;

如何用特定大小实例化x,例如这样的事情?

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

1 回答

  • 2

    为什么需要未指定尺寸?你可以这样做:

    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);
    ...
    

相关问题