Input environment variable into script to run different values automatically

3 ビュー (過去 30 日間)
In-chan Kim
In-chan Kim 2020 年 5 月 27 日
回答済み: Image Analyst 2020 年 5 月 27 日
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 Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by