How to add a specific path to Matlab in -batch mode?

38 ビュー (過去 30 日間)
Ye Cao
Ye Cao 2021 年 7 月 20 日
回答済み: Steven Lord 2021 年 7 月 20 日
I have two questions.
1)I need to run matlab in a remote server. The running mode is matlab -batch. Is there a way to add a search path to Matlab when it starts?
2)The matlab -batch “script” command seems to start Matlab each time for running a script. Is it possible to load matlab into memory without reloading matlab every time?
Thanks a lot.

回答 (2 件)

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 7 月 20 日
To my understanding and brief testing (Ubuntu, 2020a) it should work by simply adding paths as normal in/from your batch-script:
% In batch_job.m
addpath /home/you/matlab/batch_project/subdir -end % etc
Then the /home/you/matlab/batch_project/subdir directory will be at the end of the matlab-path when running:
matlab -batch batch_job
HTH

Steven Lord
Steven Lord 2021 年 7 月 20 日
For your first question, if you know you're always going to want this directory on the MATLAB path when you start your batch job you could add it to the path and save that path using addpath and savepath.
For your second question, if you're using Microsoft Windows opening MATLAB as a COM Automation Server may be helpful.

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by