macos 如何从命令行运行 Matlab?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10248049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 09:06:38  来源:igfitidea点击:

How to run Matlab from the command line?

macosmatlab

提问by Stan

Is it possible to run Matlab commands from Mac command line?

是否可以从 Mac 命令行运行 Matlab 命令?

回答by kwatford

The matlabscript is in the binsubdirectory of the MATLAB app bundle. On my machine, this means I can run it like so:

matlab脚本位于binMATLAB 应用程序包的子目录中。在我的机器上,这意味着我可以像这样运行它:

/Applications/MATLAB_R2012a_Student.app/bin/matlab

If you want this bin directory on your path (so that you can just run matlab, mex, etc), edit or create a new text file called .bash_profilein the top level of your home directory with the following line:

如果您希望此 bin 目录位于您的路径中(以便您可以只运行matlabmex等),.bash_profile请使用以下行编辑或创建一个在主目录顶层调用的新文本文件:

export PATH=/Applications/MATLAB_R2012a_Student.app/bin:$PATH

Replacing the "MATLAB_R2012a_Student" part with the name of your actual MATLAB app bundle. This will not come into effect for currently open terminals, but newly opened terminals should work properly.

用您的实际 MATLAB 应用程序包的名称替换“MATLAB_R2012a_Student”部分。这对当前打开的终端不起作用,但新打开的终端应该可以正常工作。

回答by Edric

You need the full path to the MATLAB executable, and you can use the -roption to run a command in the MATLAB that you start, as per the doc here.

您需要 MATLAB 可执行文件的完整路径,并且可以-r根据此处的文档使用该选项在您启动的 MATLAB 中运行命令。