Code covered by the BSD License  

Highlights from
XFOIL - MATLAB interface

5.0 | 9 ratings Rate this file 114 Downloads (last 30 days) File Size: 11.6 KB File ID: #30478
image thumbnail

XFOIL - MATLAB interface


Rafael Oliveira


Class interface between XFOIL and MATLAB, with the ability of running many instances in parallel.

| Watch this File

File Information

I developed this interface some time ago, so I finally decided to refine and make it available here. It provides an interface between XFOIL and MATLAB, creating the files required by XFOIL to run, and reading the results back in an easy to access polar structure.

As the goal was to perform airfoil optimization, this interface is capable of parallel execution, so that you can create multiple instances and run all at the same time, without blocking MATLAB. Also, it is possible to hide the plotting window, so XFOIL will not interrupt your work-flow while it is running.

A simple example script using an NACA 23012 is provided, showing the main features of the interface.

XFOIL is not included on this package, but the class will download and extract it for you automatically in case the XFOIL executable is not available in your path.

XFOIL is an analysis software provided by Prof. Mark Drela (from MIT), for the design and analysis of subsonic airfoils. For more info, check his website at


Naca 4 Digit Airfoil Generator and Naca 5 Digit Airfoil Generator inspired this file.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (23)
05 Dec 2014 Gregory Vernon

Gregory Vernon

03 Dec 2014 H E


I've used XFOIL-MATLAB interface with R2014a with no problems, it's been great! However, I just upgraded to R2014b and, when reading my own airfoil .dat file, I get the error:

Error using textscan
HeaderLines must be integer-valued.

Error in Airfoil (line 35)
Coordinates = textscan(fid, '%f%f','HeaderLines',HasHeader,'MultipleDelimsAsOne',true);

Changing line 26 of Airfoil.m to "HasHeader=1" instead of "HasHeader=true" seems to fix the problem. I'm not sure why, as those two statements should be equivalent.

31 Oct 2014 Arash


30 Jul 2014 SREEJITH


how can i develop interface for 'INTE'..?

29 Apr 2014 Lucas Augusto

Lucas Augusto

hey, i'm having this problem:
>> exampleXFOIL
Cannot find an exact (case-sensitive) match for 'XFOIL'

The closest match is: xfoil in C:\Users\Lucas94\Documents\MATLAB\xfoil.m

Error in exampleXFOIL (line 2)
xf = XFOIL;
Could anyone help me?

Comment only
15 Jan 2014 Guilherme


Thanks for the awesome interface!

I am though, facing some issues when trying to paralell processing XFOIL in a program, using parfor loops. Could you give me some tips or a guide on how to simultaneosly run more than one airfoil analysis at the same time? Thanks!

02 Dec 2013 James


I am a masters student of aeronautics at Durham finding this very useful, is it possible to print the tables of the results as i then need to to use the nubers to generate lift profiles. Any help would be great I am not all to familiar with matlab.

Comment only
08 Feb 2013 Brett Behrends

Brett Behrends

2 questions for you. I have been trying to get the program to print a pressure file, specifically a CPWR file. I saw that you already have the framework for it in the XFOIL.m file, but I'm have trouble getting the commands right. Also, I would like to cycle through a couple of different airfoils in the program. How would I do that?

Comment only
11 Oct 2012 Rafael Oliveira

Rafael Oliveira

Hi Matt,
To hide the xfoil window, just set (assuming x = XFOIL;)
x.Visible = false;
Any other doubts, drop me an email!

Comment only
11 Oct 2012 Matt Brown

Matt Brown

Is there any way to supress the xfoil window? I implemented this into a loop and the repeated open/close of xfoil gets to be a bit much.

Other than that, good code!

03 Mar 2012 Rajesh Senthil Kumar

Rajesh Senthil Kumar

21 Feb 2012 Mingyao


Hi Rafael,

I shot another email to your listed mailbox. Thanks.


Comment only
21 Feb 2012 Rafael Oliveira

Rafael Oliveira

Hi Mingyao,

The delete command in this case is used to delete the files whose names are stored in the cell array PolarFiles

This cell will have inside something like this:
PolarFiles = {'file1.txt', 'file2.txt', 'file3.txt'};

This is a common misunderstanding with MATLAB, about the difference between a cell array and a normal array of numbers, and how to access the elements. In the case of a cell array, you can access the content using {index}, and a sub-part of the cell as (index).
For example, let's say you have:
>> PolarFiles = {'file1.txt', 'file2.txt', 'file3.txt'};

Then, if you run:
>> PolarFiles(2)
ans = {'file2.txt'} % Returns a cell array with one element

>> PolarFiles{2}
ans = 'file2.txt' % Returns the string that was stored in the cell

If you have any further doubt, send me an email and I can answer you directly!

Comment only
20 Feb 2012 Mingyao


Hi, Rafael! Thank you for your response. I think what I don't really understand about the code is the 'delete' command. I tried a search in MATLAB Help, but the same command seems intended to delete files located in a folder or a handle object. If I simply try to delete a cell in the command window like this, MATLAB will complain. Could you please shed light on the subject? Thanks.

Comment only
20 Feb 2012 Rafael Oliveira

Rafael Oliveira

Hi! This part of the code is used to delete any polar files that might exist from previous runs, so that when XFOIL is run a few lines later, with:

this.Process = PB.start;

We can be sure that the polar files are going to be created due to this run, and not previous results. This happens very often when making small modifications in the airfoil that affects the XFOIL convergence, so that you can have a mix of old and new results.

Comment only
18 Feb 2012 Mingyao


Would you be so kind as to explain what the following lines of your code do? Thanks.

for i=1:length(this.PolarFiles)

Comment only
29 Nov 2011 Rafael Oliveira

Rafael Oliveira

Hi Matthias, I know I've already answered you, but I'll copy it here as a reference for other people:

xFlap = 0.6;
yFlap = 0;
FlapDeflection = 5;

xf = XFOIL;

% Create a NACA 5-series airfoil
xf.Airfoil = Airfoil.createNACA5('23012',150);

% Add a flap deflection to the airfoil
xf.addActions(''); %Simulate an enter, to get out of GDES mode

Comment only
24 Nov 2011 Matthias


Thanks a lot,
could you help me with implementing trailing edge deflection?

Comment only
24 Nov 2011 Matthias


28 Jul 2011 toto13000


I look that you kill Xfoil when it freezes.
Do you know that happen so that Xfoil freezes ?

Comment only
07 Mar 2011 Rafael Oliveira

Rafael Oliveira

I just implemented what I needed for my project, but you can use the XFOIL.addActions('') to send custom commands to it (just do what you want in an XFOIL section, and take note of the commands you typed).
If you have a list of commands you need, I can try to implement it into the class too...

Comment only
06 Mar 2011 sunil anandatheertha

sunil anandatheertha

Please include more of the common xfoil features .... Thx (:

Comment only
06 Mar 2011 sunil anandatheertha

sunil anandatheertha

thank you so much my friend. I saved a lotttttttttt of time using this.. Thnx. Big FAN (:

Contact us