How to manage multiple matlab processes running at the same time from python

15 views (last 30 days)
Hello,
Short Overview
I have a python program, where you can start a matlab script from.
This script collects parameters e.g. initializes them by accessing a database and starts a simulink simulation.
After the simulation is done something is plotted by another matlab function.
For some reason the plot functions hangs when I do simulation + potting in one matlab call.
I couldn't figure out why.
It works fine, when I call them seperately e.g. quit the engine from python, start a new engine and call the plot function. That raises the need to know when my simulation is done, so I can then call the matlab plot function.
Files
I added a text file where you can see my Simulation class in python. It initializes paths for matlab and python modules.
When a simulation is executed by the method execute_simulation in the ThermalSimulation class (see text file), then the matlab process detaches. I can't run the plotting function because the data is not yet generated.
I added the script where parameteres are initialized for the simulink script: "run_script.m"
And the plotting function for the plotting afterwards: "Temperature_Plot_Simulation.m"
Question
The question now is how can I obtain information about when a matlab function is finishe?
In "run_script.m" both, "save_parameters.m" and "Temperature_Plot_Simulation.m" are called, but as I said they DO NOT work, if and only if I call them from my python class from the matlab engine. But they DO from matlab.
I can get the matlab engine process id, e.g. with feature('get_pid') but this pid is from the engine. And I need to know when the simulink simulation is actually finished. Is there a way to get this information? Because only then I can quit the engine and start a new one.
I appreciate any help.
If you happen to know why the plotting won't work in the first place I am happy to know ( the function hangs, when "hold on; grid on; grid minor;" is executed successfully, and then no more ), but I didn't want to ask about both subjects in this question.
Unfortunately you can't run the code really. For the ThermalSimulation you lack the data object, and the simulink model of course.
if any more information is needed, let me know about it.

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!