File Exchange

image thumbnail

Xfoil for matlab

version 1.0.0.0 (70.7 KB) by Luca Virtuani
Xfoil rewritten as MATLAB script

39 Downloads

Updated 17 Mar 2015

View License

I developed this script some time ago and today i decide to make it available here. All functions are simply translated from fortran to matlab so the times for a single calculation are much greater than the XFoil source.
If someone manage to improve the code let me know, because I’ve been busy with other projects.
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 http://web.mit.edu/drela/Public/web/xfoil/

Cite As

Luca Virtuani (2020). Xfoil for matlab (https://www.mathworks.com/matlabcentral/fileexchange/50070-xfoil-for-matlab), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

I've had troubles with using a .dat file with a number of points which is not divisible by 8.
That causes line 554 to assign a non integer value to p.nw and the if statement in line 1194 will not be triggered.
That leads to a "Index exceeds array bounds." at line 1307.

Hi All,

I am getting the same error as Thomas.
Do anybody have a solution?
I really need it for my project!!

Thanks
Pratik

Hi Luca,
Why it is slow to finish the run. It took 32 sec on my station. Is there a way to specify the output

Thanks
Aziz

Hello
I code has an error on line 229
after some trails and errors (much more of course) I successfully ran the code.
just change the numbe
P = textscan(fid,' xtrf =%f (top) %f (bottom)','Delimiter',' ','MultipleDelimsAsOne',true,'CollectOutput',1,'HeaderLines',2); % this last number is modified from 3 to 2

It works now;
hope will work 4 u 2
r 3 to 2 in that line an d also to the line

I'm running the examples
"foil = xfoil('NACA0012',10,1e6,0.2,'oper/vpar n 12')"
"[pol foil] = xfoil('NACA0012',10,1e6,0.0,'panels n 330')"
"[pol foil] = xfoil('NACA0012',5,1e6,0.2,'oper iter 50')"
but keep getting the message
"Index exceeds matrix dimensions.

Error in xfoil (line 229)
pol.xtrf_top = P{1}(1);
"
what am i doing wrong?

IXI

Dylan Mack

Can this be used in tandem with the fmincon function for an optimization algorithm?

Scott Bollt

For anyone trying to input your own airfoil data and getting bad results, make sure you check the endpoints of your input data and compare that to the data of the file they are using. The program does not seem to play well with data that is exactly zero at the ends so make sure you give it a tiny offset, and make sure the data starts at X=1 and ends at X=1.

This code works well for me, I'm currently working on embedding it in a loop for multiple foils at a range of AoA's.

Hi there,

I'm trying to import data to matlab to run simulations on a folder of NACA airfoils, but the code stops at line 88 of your function.
Here is the error I get. . .

Field assignment to a non-structure array object.

Error in xfoil>ggcalc (line 8384)
[psi,p.qbis,p]=psilin(0,p.xbis,p.ybis,-p.sbis,p.cbis,false,true,p);

Error in xfoil>specal (line 8171)
p=ggcalc(p);

Error in xfoil (line 88)
[p]=specal(p);

Error in main_new (line 28)
[p]=xfoil(X,Y,alpha,RE,MACH);

Can you explain what the specal function does as that appears to be where the code dislikes the way p is structured. . .

Any ideas?
Thanks!

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux