Matlab立即返回退出代码 [英] Matlab returns exit code immediately

查看:227
本文介绍了Matlab立即返回退出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用python创建各种matlab .m文件,然后使用子进程运行它们.文件完成后,我要删除它们:

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)

问题是matlab.wait()从不等待,因为matlab立即返回退出代码0.还有另一种方法来检查matlab是否已完成?

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?

推荐答案

在Windows上,同时存在bin\matlab.exebin\win32\matlab.exe(或bin\win64\matlab.exe).前者只是后者的包装,并且几乎立即退出.

On Windows, there is both bin\matlab.exe and bin\win32\matlab.exe (or bin\win64\matlab.exe). The former is just a wrapper around the latter and pretty much exits immediately.

您可以直接致电bin\win32\matlab.exe或使用 -wait选项调用bin\matlab.exe时.

You can either call bin\win32\matlab.exe directly or use the -wait option when calling bin\matlab.exe.

这篇关于Matlab立即返回退出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆