Как запустить несколько сценариев MATLAB из Python в цикле?Python

Программы на Python
Anonymous
Как запустить несколько сценариев MATLAB из Python в цикле?

Сообщение Anonymous »


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] eng.tst_name_without_suffix(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 this? Is there a way to check if the session is shared already?


Источник: https://stackoverflow.com/questions/781 ... -in-a-loop

Вернуться в «Python»