Matlab calculate the flight path of a projectile with and wi

[Matlab]

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.

coefficient 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

Solution

flightpath.m

----------------------------------

%with or with air resistance.
%parameters: v0 - initial velocity, theta - angle of projection,
%k - coefficient of resistance (k=0 in absence of resistance)
%t - time instances
%returns: y - altitude of projectile, x - distance of projectile,
%u - velocity of projectile in horizontal direction,
%v - velocity of projectile in vertical direction

function [y,x,u,v]=flightpath(v0,theta,k,t)
g = 9.81; %gravitational acceleration in m/s^2
V=v0*sind(theta); %vertical component of velocity
U=v0*cosd(theta); %horizontal component of velocity
%check of air resistance present i.e. k is zero or not
if (k == 0)
    y=((-1/2)*g*(t.^2))+(V.*t);
    y=y./1000;
    x=U.*t;
    x=x./1000;
    u=U;
    v=(-g.*t)+V;  
else
    y=(((-g.*t)./k)+(((k*V+g)/k^2).*(1-exp(-k.*t))));
    y=y./1000;  
    u=U*exp(-k.*t);
    x=(u/k).*(1-exp(-k.*t));
    x=x./1000;  
    v=(V*exp(k.*t))+((g/k).*(exp(-k.*t)-1));
end
end

-----------------------------------

[Matlab] calculate the flight path of a projectile with and without air resistance. For simplification, we will assume that the projectile is small and spherica
[Matlab] calculate the flight path of a projectile with and without air resistance. For simplification, we will assume that the projectile is small and spherica

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site