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

43 visualizaciones (últimos 30 días)
Ye Cao
Ye Cao el 20 de Jul. de 2021
Respondida: Steven Lord el 20 de Jul. de 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.

Respuestas (2)

Bjorn Gustavsson
Bjorn Gustavsson el 20 de Jul. de 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 el 20 de Jul. de 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.

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by