If you know about the Nomenclature of NACA 4 digit airfoil but you are wondering how you can plot it using MATLAB or any other programming tools then this post is for you. A detailed explanation about NACA 4 digit airfoil has been presented in one of our previous posts. Since you’ve come here, I assume that you know the basics of NACA 4 digit airfoil and also the fundamentals of MATLAB.
Check out our previous post explaining the nomenclature and equations of NACA 4 digit airfoil http://geniuserc.com/naca-4-digit-airfoil-nomenclature-and-equations/
Basics of NACA 4 digit Airfoil
The NACA airfoils are airfoil shapes for aircraft wings developed by the National Advisory Committee for Aeronautics (NACA). The shape of the NACA airfoils is described using a series of digits following the word “NACA”. The parameters in the numerical code can be entered into some analytical equations to precisely generate the cross-section of the airfoil and calculate its properties. In the early periods of aircraft developments, aircraft designers used to design the shape of airfoil randomly based on intuition or some experiments.

Any NACA 4 digit airfoil can be broken down into following fragments,
NACA MPXX
Where,
M – Maximum camber divided by 100.
P – Position of maximum camber divided by 10.
XX – Thickness divided by 100.
For an example,
NACA 2412 can be broken down into these fundamental bullets,
- M = 2 , the camber is 2% of the chord.
- P = 4, the maximum camber is at 40% of the chord.
- XX =12, the thickness is 12% of the chord.
The equations, for your reference, are given down below.
(For detailed explanation about these equations, please check out our previous post about NACA 4 Digit Airfoil)


MATLAB Code:
Let us move to the part where the real fun lies , THE MATLAB.
The first step will be specifying the chord length and asking the user the 4 digits of airfoil. Here, you can prompt the user to type in the chord length as well instead of specifying by yourself.

Here the input we took from the user is in the form of string and thus we must convert it to double. For this, we use str2double and specify the location of the data we want to pull. This is illustrated in the code below. You can read the comments for further information.

Here, since M is maximum camber divided by 100, which is the camber presented in percentage of chord, so we divide the number by 100. Similarly, we do the same for the rest.
m=d1/100;
p=d2/10;
t=d34/100;
Now, its time to specify the value of a variable x, where limit will be 0 to the chord length which will be divided thoroughly into 10000 segments. You can specify the segments as per your wish. The more it is, the fine you’ll get the graph. 10,000 will be more than enough in this case.
x=linspace(0, c, 10000);
In this step, we write the general equation. And we use the for loop in order to specify two cases that we have in the equations. Later in this, we calculate the upper and lower limits.

Now is the time to plot it. We use plot function in order to do so. And labelling is done accordingly. You can modify the colour of plot as per your preference.

Here are the snapshots of NACA2412 and NACA 0012 airfoils

Thank you for reading till the end. Feel free to give your views about this post in the comments. Lastly, I want to make it easier for you to copy the code. Here you go:
c=1.524; %chord length
s=input(‘Enter the NACA 4 DIGIT AIRFOIL: ‘,’s’);
NACA=s; %4 digits
d1=str2double(s(1)); % pulls the first digit out of the scalar
d2=str2double(s(2));% pulls the second digit out of the scalar
d34=str2double(s(3:4)); % pulls the third and fourth digit out of the scalar
m=d1/100;
p=d2/10;
t=d34/100;
x=linspace(0, c, 10000);
yt =5*t*c*(.2969*(sqrt(x/c))+-.1260*(x/c)+-.3516*(x/c).^2+.2843*(x/c).^3+-.1015*(x/c).^4);
for k = 1:length(x)
if x(k) <= p*c
yc(k)=m*(x(k)/p^2)*(2*p-(x(k)/c));
dx(k)=(2*m)/p^2*(p-(x(k)/c));
elseif x(k) > p*c
yc(k)=m*((c-x(k))/(1-p)^2)*(1+(x(k)/c)-(2*p));
dx(k)=((2*m)/(1-p)^2)*(p-(x(k)/c))
end
%plot of airfoil
plot(xu,yu)
title(‘NACA 4 digit Airfoil Plot’)
xlabel(‘Chord Length’)
ylabel(‘Thickness Distribution’)
hold on
plot(xl,yl,’r’)
plot(x,yc,’g’)
axis equal
Do you want to know more about airfoil data? You can check out this site http://airfoiltools.com/airfoil/details?airfoil=naca0006-il
Tahnk you dear Prajwal Gyawali for your effort, I have a question if you could please answer it my question is why you define c=1.524 in the first line why it’s not c=1 ?
thanks in advance 🙂
That’s your input chord length of the airfoil. You can use c=1 if your airfoil has the chordlength 1.