Filter löschen
Filter löschen

matlab script to run a perl script in a loop

1 Ansicht (letzte 30 Tage)
Diego
Diego am 31 Dez. 2011
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 31 Dez. 2011
perl( sprintf('myscript.pl -w %d -f A1simple.fa >A1_%d.fa.real.%d.out', i, i, j) )
  5 Kommentare
Walter Roberson
Walter Roberson am 3 Jan. 2012
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 am 5 Jan. 2012
Thank you Walter.
I will try that in short.
Best,
Diego

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by