Can someone help me get started on my code?

3 次查看(过去 30 天)
The equations of motion can be combined algebraically to yield an equation to determine the height of the ball, y , as a function of x and the initial conditions of the ball's release (height, h, initial speed v0 and the angle of release θ) :
The parameter g = 32.2 ft/s^2 is the acceleration due to gravity. Write a "quarterback calculator" function that outputs the required angle(s) of release given an input vector of one or more throwing velocities (initial speeds) and the location ( x , y) of the target down field. The function should accept the following inputs (in order): 1.A vector of one or more throwing velocities ( v0 ) in feet/second 2.The height of release ( h ) in feet 3.The distance down field to the receiver ( x ) in feet 4.The height of the target catch ( y ) in feet 5.An initial guess for the numerical solution of θ in degrees 6.A stopping criterion for the numerical solution
Your function should use fzero along with the input numerical guess and stopping criterion to solve for the angle of release ( θ ) corresponding to each value in the input vector of release velocities. Your function should have two outputs (in order): 1.A column vector of release angles ( θ ) in degrees corresponding to each value in the input vector of initial speeds. 2.A column vector of residual values associated with the numerical solution for each release angle.

回答(1 个)

Image Analyst
Image Analyst 2016-1-23
Hint:
Make a vector t with times that the ball will be in the air, with the last number being the longest you might ever expect it to be in the air:
t = 0 : 0.1 : 15
Then get your equation for height:
h = some function of t and your other variables.
Then plot it
plot(t, h, 'b*-', 'LineWidth', 2, 'MarkerSize', 13);
grid on;
xlabel('time', 'FontSize', 15);
ylabel('height', 'FontSize', 15);
Of course find out when it hits the ground (h=0) using fzero like it asked you to. Post your code if you need further help.
  2 个评论
Troy Potensky
Troy Potensky 2016-1-23
We do not need to plot this function. We only need to use fzero in the function to find roots (I assume h=0) is what we are trying to find. But it is included as an input to the function so I am going to assume it is where y=0. how can I implement a for loop into this to help get out a column vector of angles (as stated in output section)?
Image Analyst
Image Analyst 2016-1-24
You need to use fzero to solve for alpha given x, y, v0, and h.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by