Passing a filename from a shell script to Matlab
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to pass a filename from my shell script to my Matlab script.
!/bin/bash
filename='subset_wrfout.nc'
echo $filename
module load matlab
#*************************************************************************
cat > test.m << EOF
fname = getenv('filename')
dummy = ones(1,2);
f = strcat(fname,'.mat');
save(f,'dummy');
EOF
#*************************************************************************
matlab -nojvm -nodisplay -nosplash -r "run('test.m'); exit;"
I tried using getenv. However, the result is always a null array or some root directory. The command is just not picking on the environmental variable that I created in shell. Why might this be this case? Note that I need the filename in the start as well as in the end while I am using it store the variable.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!