How do I do this assignment?
Show older comments
A basketball is thrown with an initial velocity of V0 = 12 m/s and leaves the player’s hand at xo = 0 at an elevation of yo = 1.80 m. The altitude y and the range x of the ball are related by the equation:
y(x)=yo +xtanθo –gx2 /(2V02cos2θo )
where g is the gravitational constant g = 9.81 m/s2. The basket is located 10.2 m away from the player and at a height of 1.5 m.
1a) Using the MATLAB fzero function, find the angle θo that results in the ball in the basket. Print the value out.
1b) Plot the trajectory y(x) for the value of θo that you found in part a. Put an X to mark the basket location.
For this problem, define a function in a separate file to calculate y. Use that function for guessing the initial angle to try, using fzero to find the angle, and for the final plot. You may create additional anonymous functions that call that function as needed.
1 Comment
Can you identify what is defined/known in your equation from the statement, and what is not?
What do you think that y(x) should be if you evaluate it in x=10.2m?
Would it help if you see y as a function of x and theta0 instead of just x, or even as a function of theta0 only when evaluated at a given x ?
Answers (1)
Youssef Khmou
on 13 Feb 2013
Edited: Youssef Khmou
on 13 Feb 2013
Hi Jack,
As this is an assignment, you have to post what you have achieved so far so as to see and try to orient /discuss your result,
I post here only an initiation to help you :
You have to anderstand how to define and use "Function_Handle" and see some examples of "fzero" function :
% Warning : The aim of this code is an initialization of the solution of
% Classical mechanics :
V0=12; % m/s Initial velocity
g=9.81;% small gravitational constant
% We evaluate the distances with 100 points in both x and y
x=zeros(100,1);
y0=1.8; % in meters Initial height of the ball
x_Basket=10.2;% m coordinates of the Basket
y_Basket=1.5;% m
% We define a function (derived from Newton law F=m.gamma )
% that relates y x and theta
F=@(theta) y_Basket-(y0+x_Basket*tan(theta)-g*2*x_Basket/(2* (V0^2)*cos(2*theta)))
1) Try now to figure out, how that function_Handle F is written :
Think of least square solution you have Ax=b , you have to minimize the error e such that e =||Ax-b||² to get x .
2) The unknowns become constanst in F and the variable is that angle you want .
3) To answer your first question, it still one line now perhaps no more than 1.5 inch long that you have to type using fzero to get theta
Categories
Find more on Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!