Stepwise Call of Simulink Simulation from Python
3 次查看(过去 30 天)
显示 更早的评论
We are currently trying to accomplish a circulating data flow with python and simulink like this:
- The simulation starts from a defined initial point and calculates one simulation step
- Variables of interest are sent as output to an external module (e.g. a machine learning model in python)
- The external module processes these outputs and generates a new set of variables
- The new set of variables is sent back as input to the simulation
- The loop starts over from point 1 with the new variables set until the simulation reaches the maximum of the simulation duration or generates outputs corresponding to a terminal condition
We are aware that Matlab provides great toolboxes (e.g. the Reinforcement Learning Toolbox which we already use), yet we have algorithms which we do not want to port or rebuild with said toolboxes.
In the Video MATLAB and Simulink with Python your colleague shows a possibility in which the external module is indirectly implemented within the Simulink model and called as a slave. But what we are trying to do is to make the external module the master of this construct.
We know that the MATLAB Engine API for python allows to start a simulation like
>>>import matlab.engine
>>>eng = matlab.engine.start_matlab()
>>>eng.sim("vdp")
The open question is:
Does the matlab engine allow to run the simulation stepwise like it's needed for the aforementioned data flow?
Thanks in advance for your time and effort.
0 个评论
回答(1 个)
surya venu
2024-4-3
Hi,
The MATLAB Engine API for Python facilitates running MATLAB code and functions from Python, but it may face limitations in executing simulations stepwise, as needed in your scenario.
While it allows for the execution of MATLAB commands and scripts within Python, it might not support detailed control over each step of a simulation directly from Python.
The API is generally used for integrating MATLAB code into Python scripts without offering precise control over simulation processes.
Hope it helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from Python 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!