Question: USE MATLAB!!! 2. Throwing a ball Below are all the steps you need to follow, but you should also add your own meaningful comments to
USE MATLAB!!!
2. Throwing a ball Below are all the steps you need to follow, but you should also add your own meaningful comments to the code as you write lt. 1) Start a new fle In the MATLAB Editor and save It as CTeskdp2.m 2] At the top of the flle, deflne some constants (you can plck your own varlablenames) L Inltial helght of ball at release-15m L. Gravitational acceleration 9.8 m/s Ill Velocity of ball at release -4m/s N. Angle of the velocity vector at time of release: 45 degrees Next, make a tlme vector that has 1000 linearly spaced values between 0 and 1, Induslve. Ifx is distance and y is helght, the equations below descrlbe their dependence on time and all the other parameters (Initlal helght h, gravitational acceleratlion g, inltial ball veloclty v, angle of velocity vector in degrees 0). See the following illustration: 3) 4) Solve for x andy -)/ , we multiply by /180 to convert degrees to radians. 180 l. x(1)=vcos( 180 5) Approximate when the ball hits the ground. i. li. ili. Find the index when the height first becomes negative (use find). The distance at which the ball hits the ground is value of x at that index Display the words: The ball hits the ground at a distance of X meters. (where x is the distance you found in part ii above) 6) Plot the ball's trajectory L. il. Open a new figure (use figure) Plot the ball's height on the y axis and the distance on the x axis (plot) Label the axes meaningfully and give the figure a title (use xlabel, ylabel, and title) ili. iv.Hold on to the figure (use hold on) v. Plot the ground as a dashed black line. This should be a horizontal line going from O to the maximum value ofx (use max). The height of this line should be o. (see help plot for line colors and styles) 7) Run the script from the command window and verify that the ball indeed hits the ground around the distance you estimated in 5)i. You should get something like this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
