Link AnyLogic 和 Matlab
Link AnyLogic and Matlab
我想知道 link AnyLogic 到 Matlab 是否有可能?
我需要一种从 Matlab 调用函数到 Anylogic 的方法。
我不确定你说的是哪个方向。
在 anylogic 中调用 matlab 函数:
由于 Anylogic 基于 Java,您可以使用 Java 运行时 class,并执行如下操作:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\<a long path here>\matlab.exe" -nodisplay -nosplash -nodesktop -r "run('C:\<a long path here>\mfile.m');exit;"
之后您需要从进程对象中获取输出 pr
并施展您的魔法。
在 matlab 中调用 anylogic 仿真:
看看:http://help.anylogic.com/topic/com.xj.anylogic.help/html/integration/Integration.html
这个级别的AnyLogic应该算是Java应用,题目应该表述为Link Java和Matlab。您可以搜索与 MatLab 和 Java 应用程序建立连接的不同 Java 库,允许将命令从应用程序传递到 Matlab,并获得结果。此类库的示例 — matlabcontrol. There is also example model.
UPD:Matlab提供了Java API for AnyLogic,所以你可以直接在AnyLogic中使用它。在这种情况下,不需要第三方库。为此,您需要将 engine.jar 添加到模型依赖项中,.jar 随 Matlab 一起提供,它位于:
matlab\extern\engines\java\jar
Here is the model that invokes Matlab using the respective examples 来自:
matlab\extern\examples\engines\java
我想知道 link AnyLogic 到 Matlab 是否有可能?
我需要一种从 Matlab 调用函数到 Anylogic 的方法。
我不确定你说的是哪个方向。
在 anylogic 中调用 matlab 函数:
由于 Anylogic 基于 Java,您可以使用 Java 运行时 class,并执行如下操作:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\<a long path here>\matlab.exe" -nodisplay -nosplash -nodesktop -r "run('C:\<a long path here>\mfile.m');exit;"
之后您需要从进程对象中获取输出 pr
并施展您的魔法。
在 matlab 中调用 anylogic 仿真:
看看:http://help.anylogic.com/topic/com.xj.anylogic.help/html/integration/Integration.html
这个级别的AnyLogic应该算是Java应用,题目应该表述为Link Java和Matlab。您可以搜索与 MatLab 和 Java 应用程序建立连接的不同 Java 库,允许将命令从应用程序传递到 Matlab,并获得结果。此类库的示例 — matlabcontrol. There is also example model.
UPD:Matlab提供了Java API for AnyLogic,所以你可以直接在AnyLogic中使用它。在这种情况下,不需要第三方库。为此,您需要将 engine.jar 添加到模型依赖项中,.jar 随 Matlab 一起提供,它位于: matlab\extern\engines\java\jar
Here is the model that invokes Matlab using the respective examples 来自: matlab\extern\examples\engines\java