Running an .exe file with multiple inputs
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
So I'm trying to run a .exe file called gridconv.exe. Insert is the multiple areguements that I am trying to get the code to run requentially after each other
insert= 'mdata input y n dataset tecplot output n n dim fcn 1 n n';
system('"gridconv.exe" insert');
So the .exe file works by asking a question then you submit an answer and press enter. Then it goes to the next prompt etc about 10 times. The responses to these answers is the above 'insert'. However it is not running the program this way. In my main matlab window it's still asking I manually submit each answer then submit enter. How do I get this to automatically take the arguments.
0 Commenti
Risposte (1)
Walter Roberson
il 31 Ago 2015
insertwords = regexp(insert, '\s+', 'split');
tfile = tempname();
fid = fopen(tfile, 'wt');
fprintf(fid, '%s\n', insertwords{:});
fclose(fid);
system( sprintf('%s < "%s"', 'gridconv.exe', tfile);
delete(tfile);
This presumes that every "word" should go on a different line. If that is not the case then you need to use a delimiter between the parts and code that delimiter in the regexp, or you need to code the lines using a cell array of strings.
0 Commenti
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!