I have issues calculating lift coefficient (CL), drag coefficient (CD), and thrust (T)

Hello everyone,
I am having some issues with my MATLAB code for calculating lift coefficient (CL), drag coefficient (CD), and thrust (T). The values I am getting are not close to the ones that my professor calculated by hand for CL (0.76 0.74 0.69 0.61 0.54 0.49 0.47 0.49 0.54 0.61 0.69 0.74 0.76), and I am not sure where the issue might be. Additionally, the graphs for CL, CD, and T do not look like they should. I have included my code below for reference. Can anyone help me figure out what might be causing the discrepancies?
clc;
clear;
close all;
syms CL CD T CDzero K gamma V R g m rho S
V = 202;
R = 1000;
g = 9.8;
rho = 1.058;
S = 24;
m = 7800;
gamma = [0 30 60 90 120 150 180 210 240 270 300 330 360];
%Initialize vectors for CL, CD, and T
CL_vector = zeros(size(gamma));
CD_vector = zeros(size(gamma));
T_vector = zeros(size(gamma));
%Calculate CL, CD, and T for each gamma value
for i = 1:length(gamma)
%Calculate CL
CL = (2*cosd(gamma(i)) + (V^2/(R*g))*m*g)/(rho*V^2*S);
CL_vector(i) = CL;
%Calculate CD
CDzero = 0.02;
K = 0.05;
CD = CDzero + K*CL^2;
CD_vector(i) = CD;
%Calculate T
T = m*g*sin(gamma(i)) + (rho*V^2*S*CD)/2;
T_vector(i) = T;
end
%Plot graphs
figure;
plot(gamma,CL_vector);
xlabel('gamma');
ylabel('CL');
grid on;
figure;
plot(gamma,CD_vector);
xlabel('gamma');
ylabel('CD');
grid on;
figure;
plot(gamma,T_vector);
xlabel('gamma');
ylabel('T');
grid on;
disp(CL_vector)
0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072 0.3072
Thank you in advance!

 Accepted Answer

clc;
clear;
close all;
% syms CL CD T CDzero K gamma V R g m rho S
V = 202;
R = 1000;
g = 9.8;
rho = 1.058;
S = 24;
m = 7800;
gamma = [0 30 60 90 120 150 180 210 240 270 300 330 360];
CDzero = 0.02;
K = 0.05;
%Initialize vectors for CL, CD, and T
CL_vector = zeros(size(gamma));
CD_vector = zeros(size(gamma));
T_vector = zeros(size(gamma));
%Calculate CL, CD, and T for each gamma value
for i = 1:length(gamma)
%Calculate CL
CL = 2*(m*g*cosd(gamma(i)) + (m*V^2/(R*g))*g)/(rho*V^2*S);
CL_vector(i) = CL;
%Calculate CD
CD = CDzero + K*CL^2;
CD_vector(i) = CD;
%Calculate T
T = m*g*sind(gamma(i)) + (rho*V^2*S*CD)/2;
T_vector(i) = T;
end
%Plot graphs
figure;
plot(gamma,CL_vector);
xlabel('gamma');
ylabel('CL');
grid on;
figure;
plot(gamma,CD_vector);
xlabel('gamma');
ylabel('CD');
grid on;
figure;
plot(gamma,T_vector);
xlabel('gamma');
ylabel('T');
grid on;
disp(CL_vector)
0.7619 0.7422 0.6881 0.6144 0.5406 0.4866 0.4668 0.4866 0.5406 0.6144 0.6881 0.7422 0.7619

4 Comments

CL = 2*(m*g*cosd(gamma(i)) + (m*V^2/(R*g))*g)/(rho*V^2*S); % the parenthesis was not placed correctly
the parenthesis was not placed correctly, additionally the equation also seems to be slightly incorrect, where the mass term is not multiplied in the numerator for calculating lift force term. Also, the below line
T = m*g*sind(gamma(i)) + (rho*V^2*S*CD)/2;
seems to be incorrect where the sind needs to be used instead of sin
can you attach the graphs how they look like ?

Sign in to comment.

More Answers (0)

Products

Release

R2022b

Asked:

on 16 Feb 2023

Commented:

on 19 Mar 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!