Question: This is the code i have, and figure 1 is missing the upper and lower profile, figure 3 has a jump in the graph. Could

This is the code i have, and figure 1 is missing the upper and lower profile, figure 3 has a jump in the graph. Could you fix the issues with my code and give the full new code. my code is below,
nacas =[
struct('m',0,'p',0,'tt',12, 'chord_length', 3);
struct('m',2,'p',4,'tt',12, 'chord_length', 1.5);
struct('m',5,'p',6,'tt',15, 'chord_length', 2.5)
];
% Calculations and Plots
for i =1:numel(nacas)
[xc, yc, xU, yU, xL, yL]= calculate_airfoil_coordinates(nacas(i));
plot_airfoil(xc, yc, xU, yU, xL, yL,['NACA ' num2str(nacas(i).m) num2str(nacas(i).p) num2str(nacas(i).tt)]);
end
% Function
function [xc, yc, xU, yU, xL, yL]= calculate_airfoil_coordinates(naca)
m = naca.m /100;
p = naca.p /10;
tt = naca.tt /100;
c = naca.chord_length;
% 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 = m / p^2*(2*p*x(i)- x(i))^2;
else
yc(i)= m /(1- p)^2*((1-2* p)+2* p * x(i)- x(i)^2);
dycdx = m /(1- p)^2*(1-2* p +2*p*x(i)- x(i)^2);
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
% Plot Function
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, and figure 1 is missing

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!