matlab script to run a perl script in a loop
1 次查看(过去 30 天)
显示 更早的评论
Dear all, I have a perl script that I need to run 2000 times.
myscript.pl -w i -f A1simple.fa >A1_i .fa.real. j .out
where i=3:20 and j=100.
The perl script works well for a single run, ie:
myscript.pl -w 3 -f A1simple.fa >A1_3.fa.real.1.out
However, I didn't find a way to run it in a loop.
The loop should look something like this:
for i=20:-1:3
for j=1:100
perl ('myscript.pl -w', i, '-f A1simple.fa >A1_', i, '.fa.real.', j, '.out')
end
end
Thanks in advance.
Diego
0 个评论
采纳的回答
Walter Roberson
2011-12-31
perl( sprintf('myscript.pl -w %d -f A1simple.fa >A1_%d.fa.real.%d.out', i, i, j) )
5 个评论
Walter Roberson
2012-1-3
Somehow I'm not really surprised. You could take the sprintf() result and do a split on it at whitespace to create a cell array of strings, and then you could perl(TheCellArray{:})
However, I have my doubts as to whether perl itself supports the I/O redirection operator. I think you would be better off passing the output file name to the script and having the script open the file for writing. Pass the file name as the first argument and shift() before you use <> the first time.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!