Run a java program inside Matlab with a input file.
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
luigi ventre
am 1 Dez. 2021
Bearbeitet: Kojiro Saito
am 7 Dez. 2021
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 Kommentare
Akzeptierte Antwort
Kojiro Saito
am 7 Dez. 2021
Bearbeitet: Kojiro Saito
am 7 Dez. 2021
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!