Quantcast

using system() command for batch processing in octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

using system() command for batch processing in octave

esche
Hello I'm new to Octave and was wondering if it is possible to do batch
processing,

wonderful would be something like

first run
system(command -opt1 -in  -out1)
second run
system(command -opt2 -in  -out2)
.
.
.
system (command -optn -in -outn)

I tried

formatSpec = 'system("command -opt %14.11f %14.11f %14.11f %14.11f
/..../..../FileIn.file /..../.../FileOut%d_%d.file")\n'

printf(formatSpec,list1,list2,for_operator3,for_operator4)

the command printed works well when I copy it to the command shell!

when I use:

printf("%s\n", nthargout (2, "system", "command"))

Command is working but how do I get my arguments in ??? As vectorization
here is not possible!  "command" needs to be string! but things like

d=["here stands my command string and its parameters "]

printf("%s\n", nthargout (2, "system", d))

doesn't work for me!

Why?

It would be so nice to manipulate d and every time I call printf("%s\n",
nthargout (2, "system", d)) d will be parsed inserted and the command
executed.

this works perfectly in r !

Is there something similar in octave?

Thanks chris!












_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using system() command for batch processing in octave

NJank
On Thu, Mar 23, 2017 at 10:52 PM, christoph <[hidden email]> wrote:
Hello I'm new to Octave and was wondering if it is possible to do batch processing,

wonderful would be something like

first run
system(command -opt1 -in  -out1)
second run
system(command -opt2 -in  -out2)

I first started using Octave doing exactly this. Sort of a brute force parameter sweep tool for an external program. works very well for programs that take text input/output files.  I used it for Elmer (finite element analysis) for that reason.  General process was to create dummy input files, use octave and for loops to script parameter sweeps, and file/string i/o commands to build complete input files. then call the program with the system command as you said, naming output files according to the looped parameter.
 

doesn't work for me!

Why?


not sure exactly. you just pass a string to system() and it should execute. the string should be part of the for loop, with part of the options depending on the loop variable. is your problem building the string or that the system command doesn't seem to run right with the string? have you built up some simple test cases? call a couple simple system commands to create a text file with your variable string or something similar.

ALso, what OS are you running on? It shouldn't matter, but there are a few options for the system command regarding sync or async behavior, how to send the output, etc, that can change behavior. maybe it matters for your case.  Here's a really simple example if you're using Windows. 

for idx = 1:3
  system(['dir >> test',num2str(idx),'.txt']);
endfor

this should create three text files names test1.txt, test2,txt, and test3.txt, each containing the file contents of you current working directory.

Nick J.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using system() command for batch processing in octave

NJank
On Fri, Mar 24, 2017 at 12:26 PM, christoph <[hidden email]> wrote:

Hello

I'm using Debian 8.7, Ocatve is running 64bit with compiled and tuned atlas, compiled arpack, suitesparse, qrupdate and osmesa, although print function doesn't work!

Finally I found a a way to get the thing running,

I did the loop and joined together the command from various strings

so finally what worked was following!

d=[]
u=[]
 Befehl="gdal_translate -projwin "
    Out= "/......./....../......./......../20150824_clipped"
    Inpuntfile ="-of GTiff /home/............/................./indata.tif"

for i = 1:size(Lat)(2)
for j = 1:size(Long)(2)-1  
 
ObenLinks =    [Long(j), Lat(i)];
 z=j+1;
 u=i+1;
UntenRechts =  [Long(z), Lat(u)];
 --z;
 --u;
 
  OutLO=mat2str(ObenLinks,13);
   OutLO=strrep(OutLO,"[","");
   OutLO=strrep(OutLO,"]","");
  OutRU=mat2str(UntenRechts,13);
   OutRU=strrep(OutRU,"[","");
   OutRU=strrep(OutRU,"]","");
 
Strii=num2str(i);
Strik=num2str(j);
ID=[Strii,"_",Strik];
d=[Befehl," ",OutLO," ", OutRU," ",Inpuntfile," ",Out,ID,".tif"];
system(d)
 endfor
endfor
 
Is it really nececerry to do strrep twice?

when I put in a cell array

d= mat2cell[a]

d=[a]

strrep(d, {"]","["},""}

outcome: 
{
[1,1] a]
[1,2][a
}

What did I do wrong there?

The issue with system is closed for me!

cheers chris



please keep the mailing list in the email chain. glad to hear everything is working.

Nick

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...