필터 지우기
필터 지우기

matlab script to run a perl script in a loop

조회 수: 1 (최근 30일)
Diego
Diego 2011년 12월 31일
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

채택된 답변

Walter Roberson
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
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.
Diego
Diego 2012년 1월 5일
Thank you Walter.
I will try that in short.
Best,
Diego

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by