Input environment variable into script to run different values automatically
조회 수: 3 (최근 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!
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!