How to call MATLAB from the command line several t

2019-05-25 04:46发布

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条回答
男人必须洒脱
2楼-- · 2019-05-25 05:22

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.

查看更多
登录 后发表回答