Sublime Forum

Running MATLAB scripts from Sublime Text 3 without opening n

#1

Good day,

I’m a rather inexperienced code writer, as my only experience is with MATLAB. However, I’ll soon be learning all about Python, and I was recommended to use Sublime Text as an editor. In the mean time I’d like to get a feel for the editor by using it for my MATLAB tasks, and I’m having some trouble getting it to work so that I can run MATLAB scripts from Sublime, without having it opening up a new MATLAB instance every single time I run code. Would anyone be able to assist me with this?

I’m using Windows 7 Ultimate x64, MATLAB 2013B, and Sublime Text 3. Right now I’m building my scripts using

{ "cmd": "C:/Program Files/MATLAB/R2013b/bin/matlab.exe", "-nodesktop", "-nosplash", "-r", "\"run('$file')\""], "selector": "source.m", "working_dir": "${project_path:${folder}}" }

I’m not sure if I want the nodesktop, but I can just take that away. The point is that doing this opens up a new MATLAB screen every time, which takes a while and feels rather unnecessary.

0 Likes

#2

Hi,
I have created a script, that will run current m-file opened in Sublime in Matlab after pressing any custom set key short cut. It will use opened instance of Matlab or will open a new one if none is open. Please find more information on github.com/jirkadus/sublime2matlab. I will be happy for any feedback, as at the moment is is strongly customised for my needs.

Have fun!
J.

0 Likes

#3

That is a really nice work-around solution. I have tried and it works fine! Thanks @jirkadus
But you do not actually start matlab IDE (see: http://blogs.mathworks.com/community/2010/02/22/launching-matlab-without-the-desktop/)

So there is a package called SublimeREPL (https://github.com/wuub/SublimeREPL) that make use of this property and runs MATLAB directly from Sublime Text.

You can also use that for this purpose.

0 Likes

#4

Like @jirkadus’s answer, I also recommend using AutoHotKey (or Autokey if on Linux). My setup is an extension in that as well as running the whole file, lets you select text in Sublime and paste it in the command window in Matlab. (Effectively recreating both the F5 and F9 functionality.)

See detailed instructions for Linux or Windows.

0 Likes