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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!