Как запустить несколько сценариев MATLAB из Python в цикле? ⇐ Python
-
Гость
Как запустить несколько сценариев MATLAB из Python в цикле?
I would like to run a list of MATLAB scripts from python, this list is dynamic and can change for each run. This is my function:
def RunButtonFunc(self): eng = matlab.engine.start_matlab() list_of_matlab_tests = os.listdir(self.matlab_tests_dir) eng.addpath('.\MatlabTests') for key in self.DB: tst_name_without_suffix = self.DB[key][0:len(self.DB[key]) - 2] invert_op = getattr(eng, tst_name_without_suffix, None) if callable(invert_op): invert_op(nargout=0) The problem is that if some MATLAB script name appears twice in the DB, I get this error:
The current MATLAB session is shared already. To share a session with a different name, launch a new MATLAB session, and then specify the name when you share it. Is there any workaround for this? Is there a way to check if the session is shared already?
Источник: https://stackoverflow.com/questions/781 ... -in-a-loop
I would like to run a list of MATLAB scripts from python, this list is dynamic and can change for each run. This is my function:
def RunButtonFunc(self): eng = matlab.engine.start_matlab() list_of_matlab_tests = os.listdir(self.matlab_tests_dir) eng.addpath('.\MatlabTests') for key in self.DB: tst_name_without_suffix = self.DB[key][0:len(self.DB[key]) - 2] invert_op = getattr(eng, tst_name_without_suffix, None) if callable(invert_op): invert_op(nargout=0) The problem is that if some MATLAB script name appears twice in the DB, I get this error:
The current MATLAB session is shared already. To share a session with a different name, launch a new MATLAB session, and then specify the name when you share it. Is there any workaround for this? Is there a way to check if the session is shared already?
Источник: https://stackoverflow.com/questions/781 ... -in-a-loop