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

43 visualizzazioni (ultimi 30 giorni)
Ye Cao
Ye Cao il 20 Lug 2021
Risposto: Steven Lord il 20 Lug 2021
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.

Risposte (2)

Bjorn Gustavsson
Bjorn Gustavsson il 20 Lug 2021
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 il 20 Lug 2021
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.

Categorie

Scopri di più su Search Path in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by