更新时间:2023-02-22 10:09:48
要运行脚本,您可以打开Matlab(您可以使用 -nodisplay
和防止在没有GUI的情况下运行该脚本-nodesktop
标志),然后使用 run
命令运行脚本,最后使用 exit
关闭matlab.
In order to run a script you can open Matlab (you can prevent run it without the GUI using -nodisplay
and -nodesktop
flags), then run the script using the run
command, and finally close matlab using exit
.
您可以通过一条指令在终端上完成所有操作:
You can do all this from a terminal with a single instruction:
matlab -nodisplay -nosplash -nodesktop -r "run('path/to/your/script.m');exit;"
但是,在运行脚本之前,Matlab将欢迎消息输出到控制台.要摆脱欢迎消息,只需使用 tail -n +11
However Matlab outputs the welcome message to the console before running your script. To get rid of the welcome message just skip the first 11 lines (10 depending on your Matlab version) using tail -n +11
因此,您的最终指示将是:
So your final instruction will be:
matlab -nodisplay -nosplash -nodesktop -r "run('path/to/your/script.m');exit;" | tail -n +11