I am using the MATLAB Engine API for Python
. I have a shared engine in a Python script and then another Python script connected to this shared engine. I would like to ask whether it is possible to change the parameter of the running simulation from Simulink using set_param
command. It looks like my following solution does not work. The set_param
command in the 2nd script is waiting until sim()
command from the 1st script is finished. Thanks in advance.
1st script:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.eval("matlab.engine.shareEngine('my_sim123')")
eng.eval("load_system('scheme123')",nargout=0)
eng.eval("sim('scheme123')")
2nd script:
import matlab.engine
eng = matlab.engine.connect_matlab('my_sim123')
eng.eval("set_param('scheme123/PID', 'P', '15')",nargout=0)
UPDATE: I tried to use set_param('scheme123', 'SimulationCommand','Start')
instead, but the following error occured: "You cannot use set_param to run a simulation in a MATLAB session that does not have a display." Is there any other way to change the parameter of the running sumulation with no display?