Launching UNIX Terminal using a Matlab script?

1 view (last 30 days)
Is it possible to launch the OS X Terminal and execute commands using a matlab script? I'd like to control a program called Xfoil, which has a DOS-type text console window that I can access through the terminal. I'd like to pass commands to the program through a matlab script and return a final answer. Xfoil is a text based program and its results would be text as well
Pseudo code for what I'm trying to do would look something like this: launch(Terminal)
execute : /Applications/Xfoil.app/Contents/Resources/xfoil -nodesktop
execute : naca 2412
execute : oper
execute : Re 500000
execute : cl 0
return the result to Matlab
Any ideas how I can do this, or if it's even possible?

Answers (1)

Walter Roberson
Walter Roberson on 2 Jan 2014
Java Robot Class.
You might also be able to redirect input and output.
fid = fopen('myscript.txt', 'w');
fprintf(fid, 'naca 2412\noper\nRe 500000\ncl 0\n');
fclose(fid);
system('/Applications/Xfoil.app/Contents/Resources/xfoil -nodesktop < myscript.txt > scriptout.txt');
then deal with scriptout.txt
  1 Comment
Elio Xhemalaj
Elio Xhemalaj on 2 Jan 2014
I'm trying to do the latter method of redirecting inputs and outputs, but I'm having a problem with the actual execution in the system line. I'm receiving this error:
At line 135 of file ../src/userio.f
Fortran runtime error: End of file

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!