I'm trying to pass a series of inputs to an executable via the system command, but in every way I've tried to run it, I'm prompted to manually input values in the command window. I need to run this program several hundred times, so I'd rather not enter parameters manually. The program is called solid.exe and is available here if you're feeling compelled to give it a shot.
To get solid earth tide estimates for March 12, 2005 at (65°N,123°E), I've tried
system('solid.exe 2005 3 12 65 123')
and
s = sprintf('solid.exe %s \r %s \r %s \r %s \r %s','2005', '3','12','65','123');
system(s);
and a whole host of other ways to concatenate strings. No matter what I try, the command window still wants manual data entry. I can simply type
system('solid.exe')
and when I enter parameters, it takes a fraction of a second for the program to run. How can I automate this to compute a series of lat, lon and times?

1 Kommentar

per isakson
per isakson am 31 Mär. 2015
"host of other ways" &nbsp Did you try /r instead of \r? Option in "DOS" are typically preceded by /

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

per isakson
per isakson am 27 Mär. 2015
Bearbeitet: per isakson am 29 Mär. 2015
My system don't want me to download solid.exe.
I guess you are on Windows, since you mention dos. Furthermore, I guess the problem is with solid.exe. Is there a manual?
The input argument of system is just a string value. I usually
  • experiment in the "dos-window" to figure out how to call the external program, solid in your case
  • copy&paste the successful command string, cmd_str, to Matlab
  • run system(cmd_str) from Matlab
If the external program doesn't ask for arguments in the dos-window it should not do it when run from Matlab.
If successful so far I generate cmd_str automatically.
If not successful, I would write the arguments to responsefile.txt and try something like
cmd_str = 'solid.exe < responsefile.txt';
However, I didn't try that for a very long time. See Using command redirection operators

1 Kommentar

Brilliant; tremendous thanks, Per! The working solution:
parameters = [2007 10 10 25 33]';
dlmwrite('parameters.txt',parameters)
system('solid.exe < parameters.txt');
Thank you very much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by