How to call MATLAB from the command line several times, using the same MATLAB instance every time

╄→гoц情女王★ 提交于 2020-01-23 12:49:12

问题


I have a .m script that is called from the Windows command line (aka or prompt), and I call this script with different arguments several times (50+) a day.

I tried using the matlab -r "run script.m" and the script is correctly executed, but everytime I issue this prompt command a new instance of MATLAB is opened, which is undesirable in this case.

Is there a way of identifying that there is an instance of MATLAB already running on my Windows 7 machine, and force the use of the same MATLAB instance on several external calls via Windows command line?


回答1:


As discussed here, you cannot prevent MATLAB from creating a window when starting on Windows systems, however, you can force the window to be hidden, by using the start command with the -nodesktop and -minimize options together:

start matlab -nosplash -nodesktop -minimize -r "run script.m"

or simply

start matlab -nosplash -nodesktop -minimize -r script

PS: Although this will prevent creating new instances of MATLAB (full IDE), this still will create the same number of MATLAB command windows (MATLAB processes) instead.



来源:https://stackoverflow.com/questions/26551333/how-to-call-matlab-from-the-command-line-several-times-using-the-same-matlab-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!