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

43 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by