Run a java program inside Matlab with a input file.
11 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm tring to run a java program from a matlab code. I already added the .jar file in the system static variables and I achived to lounch the progam. However I need to use a input file wrote inside matlab as a .txt file (or .dat dosen't matter). I'm using the system function:
system('java -jar mhclasses.jar');
system('java -jar javafoil.jar' );
where i can put the input file?
3 件のコメント
採用された回答
Kojiro Saito
2021 年 12 月 7 日
編集済み: Kojiro Saito
2021 年 12 月 7 日
I'm not familiar with JavaFoil, but it seems that "Script" option allows input files. If you want to input data.txt, try this.
!java.exe -cp "java\mhclasses.jar" -jar "java\javafoil.jar" Script="data.txt"
Alternatively, JavaFoil has embedded sample java code in Embedding and you can use it in MATLAB.
javaFoilPath = "C:\Path\To\MH AeroTools\JavaFoil\java";
javaaddpath(fullfile(javaFoilPath, 'mhclasses.jar'))
javaaddpath(fullfile(javaFoilPath, 'javafoil.jar'))
import MH.JavaFoil.*;
jf = JavaFoil;
% Start JavaFoil embedding
jf.startEmbedded ;
jf.runScriptLine("Options.Country(0)");
% You can input using CreateAirfoil
%jf.runScriptLine("Geometry.CreateAirfoil(0,121,12,30,0.000,40.000,0,0,1)");
% It seems that you can input txt file
jf.runScriptLine("Geometry.Open('data.txt')")
jf.runScriptLine("Polar.Analyze(500000,500000,100000,-5,15,1,100,100,0,0)");
jf.runScriptLine("Polar.Save('polar.txt')"); % Save the result
% Close JavaFoil embedding
jf.exitEmbedded;
clear jf
Again, I'm not familiar with JavaFoil, and it is rather JavaFoil specific question than MATLAB, so if you have further question, I think it's better to ask in JavaFoil community.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!