Running MATLAB script from Notepad ++

Is there any way to run MATLAB script from Notepad ++?

Obviously, I have MATLAB installed on my computer. I know that you can set the path for Notepad ++ to start when you press F5, but when I set this path to my MATLAB.exe file, it just opens another MATLAB instance.

This is not what I want, I want the actual script in Notepad ++ to be executed in an already open and running MATLAB instance.

+5
source share
3 answers

I am afraid that I am not on my home computer at the moment to test this, so the following sentence is just an attempt to try.

NppExec Notepad ++, , , F6 (, F5 Notepad ++). , , .

MATLAB ( Windows - , Windows) API ActiveX/COM. MATLAB , โ†’ MATLAB COM Automation Server. ( MATLAB) enableservice('AutomationServer'), MATLAB API.

script (, VBScript - ), Notepad ++, MATLAB COM API .

script, NppExec, F6, MATLAB.

, , , , . !

+3

NppExec F6, , :

NPP_SAVE
set local MATPATH=C:\Program Files\MATLAB\R2015a\bin\matlab.exe

cd "$(CURRENT_DIRECTORY)"

"$(MATPATH)" -nodisplay -nosplash -nodesktop -r "try, run('$(FILE_NAME)'), 
 catch me, fprintf('%s / %s\n',me.identifier,me.message), end"

( F6; ). Matlab Plot - . Matlab.

, exit"

. crontabs , Matlab .

matlab.exe -automation ...

CMD, .

+2

. -, MATLAB .

matlab.exe -automation

VB NppExec. ( API MATLAB)

'open_matlab.vb
Imports System
Module open_matlab
    ' connect to a opened matlab session
    Sub Main()
        Dim h As Object
        Dim res As String
        Dim matcmd As String

        h = GetObject(, "Matlab.Application")
        Console.WriteLine("MATLAB & Notepad++")
        Console.WriteLine(" ")
        'mainLoop
        while True
            Console.Write(">> ")
            matcmd = Console.ReadLine()
            ' How you exit this app
            if matcmd.Equals("!!") then
                Exit while
            End if
            res=h.Execute(matcmd)
            Console.WriteLine(res)
        End while
    End Sub
End Module

Then you will get a matlab-like terminal under your editor. Then you can write the code above and execute below. type !!exit the terminal. What does it look like

Tips: Do not use ctrl+cto abort the MATLAB command, because it will kill the whole process.

0
source

Source: https://habr.com/ru/post/1542902/