I am trying to start matlab from python, and then execute a really basic test.
def execute_matlab_command(command):
handle = win32com.client.DispatchEx('matlab.application')
handle.visible = True
# By using print I know that the handle is valid here
handle.Execute(command)
execute_matlab_handle("x=32")
The code runs fine, but matlab closes before handle.Execute(command)
is called. Am I missing something here, like an open() or so? I have seen others use (almost) the same code and say that it works fine, cant wrap my head around the problem.
Edit: Matlab version r2012b, python version 2.7
Edit 2: I probably found why matlab closes. I am calling DispatchEx from a GUI built in wxPython, which contains a mainloop. I tried with a simple script without GUI and it all works fine. I am leaving this question open here if someone has the same problem or has found a solution.