Question: This is the code i have so far, plotted Figure 3 has a jump in the middle of the graph that shouldn't be there, plotted

This is the code i have so far, plotted Figure 3 has a jump in the middle of the graph that shouldn't be there, plotted figure 1 is missing the black outline that shows the shape of the airfoil. The last reply i got on chegg the code was not all there/ was cut short
clear
clc
%
naca0012= struct('m',0,'p',0,'tt',12, 'chord_length', 3); % NACA 0012
naca2412= struct('m',2,'p',4,'tt',12, 'chord_length', 1.5); % NACA 2412
naca5615= struct('m',5,'p',6,'tt',15, 'chord_length', 2.5); % NACA 5615
% Calculation
[xc0012, yc0012, xU0012, yU0012, xL0012, yL0012]= calculate_airfoil_coordinates(naca0012);
[xc2412, yc2412, xU2412, yU2412, xL2412, yL2412]= calculate_airfoil_coordinates(naca2412);
[xc5615, yc5615, xU5615, yU5615, xL5615, yL5615]= calculate_airfoil_coordinates(naca5615);
% Plot
plot_airfoil(xc0012, yc0012, xU0012, yU0012, xL0012, yL0012, 'NACA 0012');
plot_airfoil(xc2412, yc2412, xU2412, yU2412, xL2412, yL2412, 'NACA 2412');
plot_airfoil(xc5615, yc5615, xU5615, yU5615, xL5615, yL5615, 'NACA 5615');
% Function to calculate airfoil coordinates
function [xc, yc, xU, yU, xL, yL]= calculate_airfoil_coordinates(naca)
% Extract parameters
m = naca.m /100;
p = naca.p /10;
tt = naca.tt /100;
c = naca.chord_length;
% Calculate coordinates
x = linspace(0, c,850);
yc = zeros(size(x));
yt =5* tt *(0.2969* sqrt(x/c)-0.1260*(x/c)-0.3516*(x/c).^2+0.2843*(x/c).^3-0.1015*(x/c).^4);
yt(isnan(yt))=0;
for i =1:length(x)
if x(i)= p*c
yc(i)= m / p^2*(2*p*x(i)- x(i)^2);
dycdx =2* m / p^2*(p - x(i));
else
yc(i)= m /(1- p)^2*((1-2*p)+2*p*x(i)- x(i)^2);
dycdx =2* m /(1- p)^2*(p - x(i));
end
theta = atan(dycdx);
xc(i)= x(i)- yt(i)* sin(theta);
yc(i)= yc(i)+ yt(i)* cos(theta);
end
xU = xc - yt .* sin(atan((2*m*(x/p).*(1-x/c)+ dycdx.*(c -2*x/c))./(1+(dycdx.*(x/c)).^2)).');
yU = yc + yt .* cos(atan((2*m*(x/p).*(1-x/c)+ dycdx.*(c -2*x/c))./(1+(dycdx.*(x/c)).^2)).');
xL = xc + yt .* sin(atan((2*m*(x/p).*(1-x/c)+ dycdx.*(c -2*x/c))./(1+(dycdx.*(x/c)).^2)).');
yL = yc - yt .* cos(atan((2*m*(x/p).*(1-x/c)+ dycdx.*(c -2*x/c))./(1+(dycdx.*(x/c)).^2)).');
end
% Function to plot airfoil
function plot_airfoil(xc, yc, xU, yU, xL, yL, label)
figure;
plot(xU, yU,'k', 'LineWidth', 1.5); hold on;
plot(xL, yL,'k', 'LineWidth', 1.5);
plot(xc, yc,'r--', 'LineWidth', 1.5);
plot([xc(1), xU(1)],[yc(1), yU(1)],'bo', 'MarkerFaceColor', 'b', 'MarkerSize', 8);
plot([xc(end), xU(end)],[yc(end), yU(end)],'bo', 'MarkerFaceColor', 'b', 'MarkerSize', 8);
grid on;
axis equal;
xlabel('Chord Length');
ylabel('Thickness/Camber');
title(label);
legend('Upper Surface', 'Lower Surface', 'Mean Camber Line', 'Location', 'Best');
end
This is the code i have so far, plotted Figure 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!