Input environment variable into script to run different values automatically

4 次查看(过去 30 天)
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!

采纳的回答

Image Analyst
Image Analyst 2020-5-27
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Enterprise Deployment with MATLAB Production Server 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by