submit m files for execution via the command line

Is there an option to start matlab as a server, in a no-gui mode and to then submit jobs for execution via the command line?
I want to avoid the time it takes for my session to start and then just run m files.

1 件のコメント

dpb
dpb 2025 年 3 月 17 日
Not AFAIK, precisely. Why not just start a session and leave it in the background? What would be the difference functionally?

サインインしてコメントする。

回答 (4 件)

Walter Roberson
Walter Roberson 2025 年 3 月 17 日

1 投票

The official way of doing this is to use MATLAB Production Server; https://www.mathworks.com/products/matlab-production-server.html
Yatin
Yatin 2025 年 5 月 28 日

1 投票

Hello,
Starting 24a, you can use the REST Function Service feature in MATLAB, to call your own functions from a 3rdparty application. For more information, you can check the documentation link: https://www.mathworks.com/help/matlab/matlab_external/get-started-with-matlab-rest-function-service.html
Thorsten
Thorsten 2025 年 3 月 17 日
編集済み: Thorsten 2025 年 3 月 17 日

0 投票

From the command line
matlab -nodisplay < myScript.m
Put
exit
as the last command in myScript.m to terminate Matlab.

1 件のコメント

John D'Errico
John D'Errico 2025 年 3 月 17 日
But this just starts a MATLAB session for each time you want to run a script. Yes, it does not have the overhead of starting the GUI display, but it still causes MATLAB to load, to re-cache toolboxes, etc., for every script.

サインインしてコメントする。

Walter Roberson
Walter Roberson 2025 年 3 月 17 日

0 投票

If you open MATLAB in no display mode, then you will get a MATLAB session that is effectively all command-line and command window. You can then type in commands and execute them.
This will have the initial overhead of starting MATLAB once per log-in.
You could reduce the overhead to once per system boot. Create MATLAB code that uses Instrument Control Toolbox "tcpserver" or uses File Exchange contribution tcpudpip https://www.mathworks.com/matlabcentral/fileexchange/345-tcp-udp-ip-toolbox-2-0-6 (not completely sure it works in modern MATLAB) to create a MATLAB session that loops accepting commands, executes the commands with evalc and sends back the results. You would match that with another program (not written in MATLAB) that creates a TCP session, accepts input commands, dispatches them to MATLAB, and receives results and displays the results.

1 件のコメント

Gal
Gal 2025 年 5 月 28 日
thanks, this looks good!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2024b

質問済み:

Gal
2025 年 3 月 17 日

回答済み:

2025 年 5 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by