通过Sublime Text 2为MATLAB创建自定义构建系统 [英] Creating custom build system for MATLAB through Sublime Text 2
问题描述
我已经编辑Sublime Text 2中的.m文件(此问题的其余部分以下简称Sublime)已经有一段时间了,最近已经习惯于使用Sublime中的build函数来运行Python代码. ,我试图为MATLAB文件设置类似的内容.我之所以尝试执行此操作,是因为我对在单独的窗口中运行代码和编辑代码感到厌倦.
I have been editing my .m files in Sublime Text 2 (henceforth referred to as Sublime for the remainder of my question) for quite some time now, and having recently become accustomed to using the build function in Sublime for running Python code, I was trying to setup something similar for MATLAB files. I am attempting to do this because I am tired of running my code and editing my code in separate windows.
在阅读文档之后,我尝试使用下面的这段非常合理的代码,其中"-r"标志启动MATLAB来运行我的文件,-nodesktop"标志启动MATLAB,而无需笨拙的Java GUI,而- nosplash"标志会启动MATLAB,而不会出现不必要的启动画面.选择器允许Sublime自动在m个文件上使用此生成系统,并且path变量将路径设置为将启动MATLAB的目录(通过运行哪个matlab"找到的目录).
Following the documentation, I tried using this very reasonable seeming code below, where the '-r' flag launches MATLAB to run my file, the "-nodesktop" flag launches MATLAB without the big hulking Java GUI, and the "-nosplash" flag launches MATLAB without the unnecessary splash screen. The selector allows for Sublime to automatically use this build system on m files, and the path variable sets the path to the directory that will launch MATLAB (directory found by running "which matlab").
我知道我可以在MATLAB GUI中设置首选的文本编辑器,但是我对此并不感兴趣.除了文本编辑器之外,我还有兴趣将Sublime用作构建系统.
I am aware that I can set an preferred text editor from within the MATLAB GUI, but I am not interested in doing that. I am interested in using Sublime as a build system in addition to a text editor.
{
"cmd": ["matlab", "-r", "-nodesktop", "-nosplash", "$file_name"],
"selector": "source.m",
"path": "/usr/local/MATLAB/R2012a/bin"
}
在我的无错.m文件上运行构建时,我在下面发现此错误,这没有任何意义.我认为这没有任何意义,因为已经使用标准命令行选项启动了MATLAB,并且也收到了MATLAB内部错误.
Upon running build on my errorless .m file, I find this error below, which doesn't make sense. I don't think it makes sense because have launched MATLAB with the standard command line options, and am receiving MATLAB internal errors, too.
/usr/local/MATLAB/R2012a/bin/matlab: 1: /usr/local/MATLAB/R2012a/bin/matlab: awk: not found
/usr/local/MATLAB/R2012a/bin/matlab: 1: /usr/local/MATLAB/R2012a/bin/matlab: expr: not found
Internal error 2: Could not determine the path of the
MATLAB root directory.
original command path = /usr/local/MATLAB/R2012a/bin/matlab
current command path = /usr/local/MATLAB/R2012a/bin/matlab
Please contact:
MathWorks Technical Support
for further assistance.
[Finished in 0.1s with exit code 1]
其他人是否有这样的问题,例如通过备用构建系统调用MATLAB脚本?如果该信息有用,我还没有尝试在Ubuntu 12.04以外的任何其他操作系统上的Sublime中为MATLAB建立构建系统.
Has anybody else had problems like this invoking MATLAB scripts via an alternate build system? I have not tried to set up a build system for MATLAB in Sublime on any other operating system besides Ubuntu 12.04, if that information is useful.
现在可以使用!
这是我的Matlab.sublime-build
:
{
"cmd": ["/usr/local/MATLAB/R2012a/bin/matlab", "-nosplash", "<$file_name"],
"selector": "source.m"
}