Running a MATLAB script from Notepad++

前端 未结 3 1290
野性不改
野性不改 2021-02-06 12:52

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

3条回答
  •  被撕碎了的回忆
    2021-02-06 13:30

    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!

提交回复
热议问题