Input environment variable into script to run different values automatically

3 visualizaciones (últimos 30 días)
Hi, I'm running a matlab script on a different server, and I want it to automatically input a value into a script, so that I can run it once, and have different versions of the scrips running independently.
I know that if I use something called an environment variable, it will work, I just don't know how!
From the server side of things:
#PBS -J 1-5
matlab -nodesktop -nosplash -nodisplay < RunHPC_parallel${PBS_ARRAY_INDEX}s.m
And that will make it
RunHPC_parallel1s.m, RunHPC_parallel2s.m ... RunHPC_parallel5s.m
I need to be able to make the J feed into my script and adjust a value within my script.
Specifically, the J in
formparams=form2params(J,:);
I think it's something to do with this: ${PBS_ARRAY_INDEX}
But not sure how!
Thanks!

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Mayo de 2020
You can get the environment variable inside your program with getenv().
Description
value = getenv(name) searches the operating system environment variable list for text of the formname=value.
On UNIX® platforms, the shell you use to start MATLAB® determines the operating system environment. For example, starting MATLAB on a Mac platform from the Applications folder creates a different shell environment from starting MATLAB from Terminal.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by