Question: The goal of this assignment is to plot the trajectory of a projectile given an initial launch velocity and angle. It will require user inputs

The goal of this assignment is to plot the trajectory of a projectile given an initial launch velocity and angle.
It will require user inputs for initial velocity (m/s) and angle (degrees), time step definition, and plotting of
projectile path (vertical distance vs horizontal distance). Additionally, identify the maximum altitude and
horizontal distance traveled. You will write code for this assignment in Python and Matlab.
Python Instructions
1.(10 points) Create user inputs for initial velocity and launch angle and set equal to variables V
and angle. Define a variable g for gravity constant (g =9.8 m/s2
).
2.(10 points) Define time step using numpy.linspace()(ex: timestep = numpy.linspace()). This will
create a time step array for the present problem definition. I suggest using 0-5 seconds as a starting
point and adjust as needed. (You will need to adjust your code to handle large velocities, so a
larger timestep will be needed. Your code should be able to accept and process such extreme
velocity and launch angles, e.g.1000 m/s @ 60 deg angle, etc)
3.(30 points) Using kinematic equations, determine the horizontal and vertical positions for the
projectile. **Remember to convert from degrees to radians when using math.sin() and math.cos(),
etc.
hPos = V*cos(angle)*timestep
vPos = V*sin(angle)*timestep (0.5*g*(timestep**2))
4.(10 points) Determine the maximum altitude achieve using:
vMax = max(vPos)
5.(10 points) Determine the maximum horizontal distance traveled before projectile hits ground
level. Use the following equations:
time =2*V*sin(angle)/g
hMax = V*cos(angle)*time
6.(30 points) Plot the projectile path, vMax, hMax using plt.plot(). Use line/marker styling as needed.
Add axis labels and title, adjust axis boundaries as needed.
Matlab Instructions
7.(10 points) Create user inputs for initial velocity and launch angle and set equal to variables V
and angle.(ex: V = input(Enter initial velocity in m/s: )) Also define gravity by: g =9.8
8.(10 points) Define time step [start:step:end],(ex: timestep =[0:0.5:2] will create a timestep array
of [00.511.52]. I suggest using [0:0.05:5] as a starting point and adjust as needed.
9.(30 points) Using kinematic equations, determine the horizontal and vertical positions for the
projectile.
hPos = V*cosd(angle)*timestep
vPos = V*sind(angle)*timestep (0.5*g*(timestep.^2))
Note: use .^ when squaring individual values from the timestep array.
10.(10 points) Determine the maximum altitude achieve using:
vMax = max(vPos)
Note: max() is a function built into Matlab.
11.(10 points) Determine the maximum horizontal distance traveled before projectile hits ground
level. Use the following equations:
time =2*V*sind(angle)/g
hMax = V*cosd(angle)*time
12.(30 points) Plot the projectile path, vMax, hMax using plot(). Use line/marker styling as needed.
Add axis labels and title, adjust axis boundaries as needed. Example:
plot(hPos,vPos,'.b',hMax,0,'rX',hMax/2,vMax,'rX','LineWidth', 3,'MarkerSize',12)
xlabel('Horizontal Distance, meters') ylabel('Altitude, meters')
title('Projectile Trajectory') axis([0 hMax+50 vMax+5])
13. Save your program files (.py and .m) and plot images (.png) to a single folder, zip and upload to
Blackboard by 11:59p.m. on April 28,2024(Follow file naming convention in syllabus).

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!