问题
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