Is there a way of running a MATLAB script from Notepad++?
Obviously I have MATLAB installed on my computer. I know you can set a path for Notepad++to run when you hit F5, but when I set this path to my MATLAB.exe file, it simply opens another instance of MATLAB.
This is not what I want, I want the actual script in Notepad++ to be executed in the already open and running instance of MATLAB.
I'm afraid I'm not on my home computer at the moment to test this out, so the following is just a suggestion for you to try.
If you take a look at the NppExec plugin for Notepad++, you'll see that with it you can specify a command to be run when you hit F6 (like an enhanced version of hitting F5 in the regular Notepad++). You can also give it variables such as the path to the current file, and the name of the current file.
MATLAB (on Windows at least - I assume you're on Windows) makes available an API over ActiveX/COM. If you search in the MATLAB documentation for details, it's under External Interfaces -> MATLAB COM Automation Server. By running (in MATLAB) the command
enableservice('AutomationServer')
you will set up your running instance of MATLAB to receive instructions over this API.You should be able to write a small script (perhaps in VBScript or something similar) that will take as input arguments the path and filename of the current file in Notepad++, and will then connect to a running instance of MATLAB over the COM API and execute the file's contents.
Set this script to be executed in NppExec when you hit F6, and it should then run the current file in the open instance of MATLAB.
As I say, the above is just speculation as I can't test it out right now, but I think it should work. Good luck!
Use NppExec add-on and press F6, copy paste the following and save the script:
then run (press F6; enter). Matlab Console and Plot windows still open and stay open. Error messages will be displayed in opening Matlab command window. Adding
to the last command will make it quit and close again. If you want to run an automated application with crontabs or the like, check Matlab external interface reference for automation.
Also works in cmd terminal, but you have to fill in the paths yourself.
This is a usable implementation upon Sam's idea. First, execute MATLAB in automation mode like this.
Next, compile and execute this following VB in NppExec plugin. (which is to use MATLAB automation API)
Then you'll get a matlab-like terminal below your editor. You can then code above and execute below. type
!!
to exit the terminal. What it looks likeTips: don't use
ctrl+c
to interrupt the MATLAB command, because it will kill the whole process instead.