假设我有这个MATLAB函数
function a = testfun(filename)
% do something with file contents and create some variable a
disp(a);我希望有一个运行在Cygwin上的shell脚本,如下所示:
./testscript.sh < inputforfunction.txt > outputoffunction.txt输入文件将包含我需要的数据。运行此命令后,输出文件将包含运行testfun(文件名)的结果。
到目前为止,我可以将输出写入文件outputoffunction.txt。
问题是我想读取文件名"inputforfunction.txt".
我可以在文件内容中读取,但不能读取文件名,有什么提示吗?谢谢!
发布于 2013-03-24 10:07:00
为什么不将文件作为参数传递给bash脚本呢?
./testscript.sh inputforfunction.txt > outputoffunction.txt在脚本中,您可以访问$1 --它将计算为'inputforfunction.txt'。
发布于 2013-09-18 06:42:04
read file_name
./testscript.sh < $file_name > outputoffunction.txthttps://stackoverflow.com/questions/15587602
复制相似问题