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

[xPos,yPos,U,V] = projectile_motion_with_drag(timeVec, initial_velocity_magnitud

ID: 3667663 • Letter: #

Question

[xPos,yPos,U,V] = projectile_motion_with_drag(timeVec, initial_velocity_magnitude, launch_angle_deg, drag_coefficient, gas_density, cross_sectional_area, mass)
where xPos, yPos are the projectile’s positions at the times in timeVec and U, V are the projectile’s horizontal and vertical velocity components at the times in timeVec. timeVec should include enough times to describe the full trajectory smoothly (a starting point could be timeVec = 0:0.01:2) The function should return all zeros for any times less than 0 and the appropriate values for times after the projectile lands. Note that you will need to separate out the ascent and descent portions of the trajectory and use the appropriate equations for each part. You can use the find function to help identify which elements of the input timeVec go with which equation.

How do I create this function?

Explanation / Answer

Solution: See the code below

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

%function definition for projectile motion with drag
% terminal velocity - Vt = sqrt ( (2 * m * g) / (Cd * r * A) ) where m = mass, Cd = drag coefficient, r = gas density, A = cross-sectional area
% vertical velocity - V = Vt[(Vo - Vt * tan(g * t / Vt)) / (Vt + Vo * tan (g * t / Vt))]
% vertical position - y = (Vt^2 / (2 * g)) * ln ((Vo^2 + Vt^2)/(V^2 + Vt^2))
% horizontal velocity - U = Vt^2 * Uo / (Vt^2 + g * Uo * t)
% horizontal position - x = (Vt^2 / g) * ln( (Vt^2 + g * Uo * t) / Vt^2 )
function [xPos,yPos,U,V] = projectile(timeVec,initial_velocity_magnitude,launch_angle_deg,drag_coefficient,gas_density,cross_sectional_area,mass)
   %constant PI
   PI = 3.1416;
   %gravitational acceleration
   g=9.8; %in m/sec^2
   %calculation of terminal velocity
   Vt = sqrt((2*mass*g)/(drag_coefficient*gas_density*cross_sectional_area));
   %horizontal initial velocity
   U0 = initial_velocity_magnitude*cos(launch_angle_deg*(PI/180));
   %vertical initial velocity
   V0 = initial_velocity_magnitude*sin(launch_angle_deg*(PI/180));
  
   %intialize xPos, yPos, U and V
   xPos=zeros(1,length(timeVec)); %vector for x (horizontal) positions
   yPos=zeros(1,length(timeVec)); %vector for y (vertical) positions
   U=zeros(1,length(timeVec)); %vector for U (horizontal) velocities
   V=zeros(1,length(timeVec)); %vector for V (vertical) velocities
   %loop to calculate xPos, yPos, U and V at different times in timeVec  
   for t=1:length(timeVec)
       xPos(t) = (Vt^2/g)*ln((Vt^2+(g*U0*t))/(Vt^2)); %horizontal position at ant time t
       yPos(t) = (Vt^2/(2*g))*ln((V0^2+Vt^2)/(V^2+Vt^2)); %vertical position at ant time t
       U(t) = (Vt^2*U0)/(Vt^2+(g*U0*t)); %horizontal velocity at any time t
       V(t) = Vt*((V0 - Vt * tan((g*t/Vt)*(PI/180)))/(Vt+V0*tan((g*t/Vt)*(PI/180))));    %vertical velocity at any time t
   end
end

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote