【发布时间】:2020-03-03 20:27:28
【问题描述】:
我想编写一个在 matlab 中运行多个测试的脚本。 首先我运行:
TestsPath=$(find . -path "Tests")
返回:
a/b/Tests/ b/c/Tests/ c/d/Tests/
然后我尝试启动 matlab 并传递这些(现在只打印它们)
matlab -nosplash -nodesktop -r "run(RunAllTests(${TestsPath}));"
我的 matlab 函数如下所示:
function [] = RunAllTests(varargin)
for i=1:nargin
disp(varargin{i});
end
end
但是这个
run(a/b/Tests
|
Error: This statement is incomplete.
所以它似乎在涉及第一个空白时会中断。
可以这样做吗?
【问题讨论】:
-
如果不能一一传递路径,为什么不在 bash 中循环遍历它们呢?只需为对 MATLAB 的调用编写一个包装器,它会遍历找到的所有测试目录。
-
但是我需要为每个测试用例重新打开 matlab。因为我不能(在 bash 脚本中)启动 matlab,然后不断地将东西传递给它。对吗?
-
或者,如果答案有效,请编写一个 bash 包装器,将撇号和逗号插入您的
TestPath字符串并传递它。由于它在空格上中断,我认为您不能在 MATLAB 中执行此操作?因此将带有空格的字符串传递给函数,然后执行strplit并使用分隔的参数
标签: bash matlab scripting command-line-arguments