在批处理模式运行Matlab的 [英] run Matlab in batch mode
问题描述
喜
在我看来,有两种方法可以在批处理模式下运行Matlab的:
Hi It seems to me that there are two ways to run Matlab in batch mode:
第一个:
unset DISPLAY
matlab > matlab.out 2>&1 << EOF
plot(1:10)
print file
exit
EOF
第二个选择使用-r MATLAB_command
The second one uses option "-r MATLAB_command":
matlab -nojvm -nosplash -r MyCommand
这些是两种等价?
Are these two equivalent?
什么&所述;&下; EOF?和最后一个EOF中的第一个方法是指
What does "<< EOF" and the last "EOF" mean in the first method?
感谢和问候!
推荐答案
第一种方法简单<一个href=\"http://en.wikipedia.org/wiki/Redirection%5F%28computing%29#Redirecting%5Fto%5Fand%5Ffrom%5Fthe%5Fstandard%5Ffile%5Fhandles\">redirects标准输出&GT; matlab.out
,标准误差 2 - ;&放大器; 1
到文件 matlab.out
。
The first method simply redirects the standard output > matlab.out
and the standard error 2>&1
to the file matlab.out
.
然后使用通过输入到MATLAB的定界符方式(这不是具体到MATLAB,这是通过多条线路的输入命令的一般行程序)的方法。
Then it uses the heredoc way of passing input to MATLAB (this is not specific to MATLAB, it is a method of passing multiple lines as input to command line programs in general).
语法&LT;&LT;
后面跟着一个唯一的标识符,那么你的文字,最后唯一的ID来完成。
您可以在外壳试试这个:
The syntax is <<
followed by an unique identifier, then your text, finally the unique id to finish.
You can try this on the shell:
cat << END
some
text
multiple lines
END
使用 -r
选项的第二个方法启动MATLAB和立即执行通过了声明。这可能是某些命令或脚本或函数的道路上找到的名称。
它等同于做这样的事情:
The second method of using the -r
option starts MATLAB and execute the statement passed immediately. It could be some commands or the name of a script or function found on the path.
It is equivalent to doing something like:
python -c "print 'hello world'"
请参阅此页面为其他启动选项的列表。
Refer to this page for a list of the other start options.
这篇关于在批处理模式运行Matlab的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!