Because we are computing the trajectory in a vacuum


This objectives of this problem are to give you experience creating MATLAB functions, using iteration, and solving a numerical problem in MATLAB.
You will write a program that computes the trajectory of a ball. Your main script will prompt for the ball's initial angle (in degrees), velocity (in meters per second), an initial height above the ground (in meters), and a time interval between each coordinate pair (in
seconds). For this simulation, we will assume the ground is level, the ball is traveling in a vacuum. You will compute the coordinates of the ball at uniform time intervals, until the ball is on or in the ground.
Theory
Because we are computing the trajectory in a vacuum on a flat world, the equations of motion are very simple. Assume that the initial velocity is , the initial angle of the velocity vector is , and the initial height is . We can compute the initial components of the velocity vector as:
Since there is no force acting on the horizontal direction, we know the horizontal component of the acceleration vector is:
and hence the horizontal component of the velocity vector is constant:
Thus the position at time is
Derivation of the vertical vector components is similarly easy. Since the only vertical force is gravity, the vertical component of the acceleration vector is:
where m/s2 is the gravitational constant on earth. Integrating over time, we find:
We also find:
Program Specifications
Create a function, calculate_path, with the following inputs and outputs:
[tp,xp,yp,xv,yv] = calculate_path(ang, v0, y0, dt, ft)
This computes points on the trajectory when the initial height in meters is y0, the angle in degrees is ang, the initial speed in m/s is v0, and the time step is dt. The results include horizontal positions in xp and vertical components in yp, where each (xp(i), yp(i)) the
coordinates of ball at time tp(i), which is (i-1)*dt. The other results are horizontal components of velocity in xv, and vertical components of velocity in yv, where each (xv(i), yv(i)) are vector velocity components at time t(i). The value of the last element of yp should be <= 0, or the last element of tp should be >= tp, the final time. In other words, calculate the trajectory until either the ball has hit the ground, or it has been in flight for ft seconds, whichever comes first.
You must also create a script, homework2.m, that will prompt for the initial height, angle,velocity, and time step. The script will then call calculate_path to compute the points of the trajectory. The script will print the time of the final step in the trajectory, and the speed
of the ball at that time. Finally, the script will plot the trajectory in a figure.
You must turn in your homework2.m script, your calculate_path function, and any other functions you might create to solve this problem. Be sure your work is well commented! In particular, don't forget the heading comments in your main script indicating who the
programmers are, etc.
Sample Output
Running the script might produce output like this:
Please enter the initial speed of the ball (m/s): 1000
Please enter the initial height of the ball (m): 500
Please enter the angle of velocity from horizontal (degrees): 30
Please enter the time step (seconds): 0.1
Please enter the final time (seconds): 500
Final time is:
103.1000
Final speed is:
1.0052e+03
>>
This would create a plot like this:
Other Notes
We will be using and modifying the calculate_path function in other homework problems,so it is important that you follow the specification shown here. You will want to keep it for future assignments. As for your script, you may embellish it as you please, as long as the result is basically what is specified here. Please do not animate output, but feel free to add legends to the axes, draw a cannon to launch the ball, etc. But none of this is required.
Grading
This assignment will be graded out of 100 points, assigned as follows:
• Properly commented: 20
• There is a proper calculate_path function, with the proper parameters and return values: 10 points for the correct name, 5 points for the correct return values, 
• The calculate_path function uses iteration: 
• The calculate_path function computes correct results: 
for positions, 10 points for velocities. These are results are all vectors.
• The trajectory is plotted:
• The final velocity is correctly computed:

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Because we are computing the trajectory in a vacuum
Reference No:- TGS0146243

Expected delivery within 24 Hours