I am creating various matlab .m-files with python and then run them using subprocess. When the files are finished I would like to delete them:
command = ['C:\\MatlabR2012b\\bin\\matlab.exe', '-nodesktop', '-nosplash', '-r', 'mfile']
matlab = subprocess.Popen(command) # launch matlab with m file
matlab.wait() # wait for matlab to finish before deleting .m file
print "delete"
os.remove(self.filename)
The problem is that matlab.wait() never waits, since matlab returns exit code 0 immediately. Is there another way to check if matlab has finished?