Ask Computer Engineering Expert

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:

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9653773

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As