matlab script to run a perl script in a loop

1 visualización (últimos 30 días)
Diego
Diego el 31 de Dic. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by