Pass a parameter vector to an exe file

12 ビュー (過去 30 日間)
erasmo mancusi
erasmo mancusi 2011 年 12 月 1 日
編集済み: dpb 2022 年 9 月 1 日
Hi to all, I have a exe file generated from fortran that I need to run in Matlab for different parameters. The exe file require that I input by keyboard the parameter and the option in matlab: system('myprogram.exe') (equivalently ! or dos or unix) work in the same way: need the input by the keyboard. Exist the possibility to pass the input in a different way? I have tried system('myprogram.exe PARAMETER') but doesn't work. Thank you in advance to all. erasmo
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2011 年 12 月 1 日
Did you mean that the executable prompts the user to enter the input? Or does it use command-line arguments? How would you provide the input from a system shell?

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 12 月 1 日
try system('myprogram.exe < InputParameters.txt') where InputParameters.txt is a text file that you created ahead of time, just type in the parameters to the text file as if you are type it in command window, include the carriage return.
  2 件のコメント
Kaustubha Govind
Kaustubha Govind 2011 年 12 月 1 日
Nice!
erasmo mancusi
erasmo mancusi 2011 年 12 月 1 日
編集済み: dpb 2022 年 9 月 1 日
First of all I'd like to thank Jiang for his replay.
Then I share the solution:
fid = fopen('filename1', 'wt');
fprintf(fid, '%6f \n', state variables); %write out the input parameters the program will need
fprintf(fid, '%6f \n', PAR1); %write out the input parameters the program will need
system(['myprogram.exe < ' 'f.7']);%ruxecutable with content of fname as
% the myprogram.exe create a file named filenam2 where this program write the NDIM dtate variables and the new parameter (at each iteration the myprogram.exe close the file and then rewrite on it)
A = importdata('filename2'); % here I import the new data that will be re-assigned to filename1
statevariable=A(1:NDIM,1);
PAR1=A(NDIM+1,1);
fclose(fid);
thx
eramso

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by