Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

calculate the flight path of a projectile with and without air resistance. For s

ID: 3679124 • Letter: C

Question

calculate the flight path of a projectile with and without air resistance. For simplification, we will assume that the projectile is small and spherical in shape. Your task is to write a MATLAB programs that calculate the flight path, range and flight time for several values of coefficients of resistance of the projectile, and plot the results.

coeficient of resistance= 0-.08 with step size of .001

initial velocity=600

release angle =60

If we assume that the projectile is launched from the surface of the Earth, i.e., at y0 = 0, then the altitude of the projectile as a function of time is

Y(t)=(-1/2)*g*t^2 +Vt;

where g = 9.81 m/s2 is the gravitational constant, t is time (in seconds), and V = v0 sin (in meters per second). The distance of the projectile from the launching position as a function of time is

x(t)=U*t

where U = v0 cos . The velocity of the projectile in the horizontal direction, i.e., parallel to the x-axis, is

u(t)=U

and the velocity in the vertical direction, i.e., parallel to the y-axis, is

v(t)=-gt+V

If we include the effects of air resistance, then the altitude of the projectile as a function of time can be approximated as

y(t)=-gt/k+((kV+g)/k^2)*(1-e^(-kt))

where k is the coefficient of resistance (with the unit 1/s). The distance of the projectile relative to the initial position as a function of time is

x(t)=(u/k)(1-e^(-kt))

The velocity of the projectile in the horizontal direction is

u(t)=ue^(-kt)

and in the vertical direction

v(t)=Ve^(kt)+(g/k)*(e^(-kt)-1)

create

1. A MATLAB function, flightpath.m, capable of calculating the flight path of a projectile, with and without air resistance, given an initial speed v0, an angle of departure relative to the horizontal, and a coefficient of resistance k.

2. A script, main_flightpaths.m, which uses the function flightpath.m to calculate and the function plot_flightpaths.m to plot the following: a. Altitude, y, as a function of distance, x (see Fig. 2) b. Altitude, y, as a function of time, t c. Horizontal velocity, u, as a function of time, t d. Vertical velocity, v, as a function of time, t For these plots, assume v0 = 600 m/s, = 60 deg., and k = [0 0.005 0.01 0.02 0.04 0.08] s-1 .

3. A script, main_range.m, which uses the function flightpath.m to calculate and function plot_range.m to plot the following: a. Range as a function of k b. Total flight time as a function of k For these plots, assume v0 = 600 m/s, = 60 deg., and k from 0 to 0.08 s-1 with step size of 0.001 s-1 .

Explanation / Answer

Please find below the MATLAB code which can be used to calculate  flight path, range and flight time:

flightpath.m:-

clear all;

global rkcoef ad76

global tdata aoadata bankdata

global req mu omega mass sref

% define angular conversion factors

rtd = 180.0 / pi;

dtr = pi / 180.0;

% radius of the earth (kilometers)

req = 6378.14;

% gravitational constant of the earth (km**3/second**2)

mu = 398600.4415;

% earth rotation rate (radians/second)

omega = 7.2921151467d-5;

% initialize rkf78 function

rkcoef = 1;

% ---------------------------------
% define propulsion characteristics
% ---------------------------------

% aerodynamic reference area (km**2)

sref = 2.499091776e-4;

% read atmospheric density data

[fid, ad76] = read76;

% ------------------------------
% read flight controls data file
% ------------------------------

m = csvread('sts_cr.csv');

tdata = m(:, 1);

aoadata = dtr * m(:, 2);

bankdata = dtr * m(:, 3);

ndata = size(tdata);

% --------------------------------------
% define initial flight path coordinates
% --------------------------------------

% altitude (kilometers)

xalt = 121.92;

% relative velocity (kilometers/second)

vrel = 7.80288;

% geographic declination (degrees)

dec = 0.0d0;

% geographic longitude (degrees)

elon = 0.0d0;

% azimuth (degrees)

azim = 90.0d0;

% flight path angle (degrees)

fpa = -2.39780555815067d0;

% vehicle mass (kilograms)

mass = 92079.25;

% -------------------------------
% load initial integration vector
% -------------------------------

% geocentric altitude (kilometers)

yi(1) = xalt;

% longitude (radians)

yi(2) = dtr * elon;

% geocentric declination

yi(3) = dtr * dec;

% relative speed (kilometers/second)

yi(4) = vrel;

% flight path angle (radians)

yi(5) = dtr * fpa;

% flight azimuth (radians)

yi(6) = dtr * azim;

fprintf(' program demo_fpeqm ');

fprintf(' initial flight path coordinates');
fprintf(' -------------------------------');

fprintf(' altitude %14.4f meters', 1000.0 * yi(1));

fprintf(' velocity %14.4f meters/second', 1000.0 * yi(4));

fprintf(' declination %14.4f degrees', rtd * yi(3));

fprintf(' longitude %14.4f degrees', rtd * yi(2));

fprintf(' azimuth %14.4f degrees', rtd * yi(6));

fprintf(' flight path angle %14.4f degrees ', rtd * yi(5));

% data generation step size (seconds)

deltat = 5.0d0;

% final simulation time (seconds)

tfinal = tdata(end);

% number of differential equations

neq = 6;

% truncation error tolerance

tetol = 1.0d-10;

tf = 0.0d0;

nplot = 0;

% integrate equations of motion and create data arrays

while (1)

h = 1.0d0;

ti = tf;

tf = ti + deltat;

if (tf > tfinal)
tf = tfinal;
end

% evaluate lift and drag coefficients

alt = yi(1);

alpha = interp1(tdata, aoadata, ti, 'cubic');

bank = interp1(tdata, bankdata, ti, 'cubic');

yf = rkf78 ('fpeqms', neq, ti, tf, h, tetol, yi);

% load data arrays for plotting

nplot = nplot + 1;

% simulation time (seconds)

xplot(nplot) = ti;

% altitude (meters)

yplot1(nplot) = 1000.0 * alt;

% angle-of-attack (degrees)

yplot2(nplot) = rtd * alpha;

% bank angle (degrees)

yplot3(nplot) = rtd * bank;

% longitude (degrees)

yplot4(nplot) = rtd * yf(2);

% declination (degrees)

yplot5(nplot) = rtd * yf(3);

% velocity (meters/second)

yplot6(nplot) = 1000.0 * yf(4);

% flight path angle (degrees)

yplot7(nplot) = rtd * yf(5);

% azimuth (degrees)

yplot8(nplot) = rtd * yf(6);

if (tf == tfinal)
break
end

% reload integration vector

yi = yf;
end

fprintf(' final flight path coordinates');
fprintf(' -----------------------------');

fprintf(' altitude %14.4f meters', 1000.0 * yf(1));

fprintf(' velocity %14.4f meters/second', 1000.0 * yf(4));

fprintf(' declination %14.4f degrees', rtd * yf(3));

fprintf(' longitude %14.4f degrees', rtd * yf(2));

fprintf(' azimuth %14.4f degrees', rtd * yf(6));

fprintf(' flight path angle %14.4f degrees ', rtd * yf(5));

% plot altitude

plot(xplot, yplot1);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('altitude (meters)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm1.eps;

% plot speed

figure;

plot(xplot, yplot6);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('speed (meters/second)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm2.eps;

% plot flight path angle

figure;

plot(xplot, yplot7);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('flight path angle (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm3.eps;

% plot azimuth angle

figure;

plot(xplot, yplot8);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('azimuth angle (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm4.eps;

% plot declination

figure;

plot(xplot, yplot5);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('declination (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm5.eps;

% plot longitude

figure;

plot(xplot, yplot4);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('longitude (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm6.eps;

% plot declination versus longitude

figure;

plot(yplot4, yplot5);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('longitude (degrees)', 'FontSize', 12);

ylabel('declination (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm7.eps;

% plot angle-of-attack

figure;

plot(xplot, yplot2);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('angle-of-attack (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm8.eps;

% plot bank angle

figure;

plot(xplot, yplot3);

title('STS Maximum Crossrange', 'FontSize', 16);

xlabel('simulation time (seconds)', 'FontSize', 12);

ylabel('bank angle (degrees)', 'FontSize', 12);

grid;

print -depsc -tiff -r300 demo_fpeqm9.eps;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote