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 件のコメント

per isakson
per isakson 2015 年 3 月 31 日
"host of other ways" &nbsp Did you try /r instead of \r? Option in "DOS" are typically preceded by /

サインインしてコメントする。

 採用された回答

per isakson
per isakson 2015 年 3 月 27 日
編集済み: per isakson 2015 年 3 月 29 日

1 投票

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 件のコメント

Chad Greene
Chad Greene 2015 年 3 月 28 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by