I had the task of writing a program that will calculate the following for the golf ball:
1.Calculated and printed the angles and initial velocities at which the ball falls on the field.
2.Calculated and printed the angles and initial velocities at which the ball falls into the hole (hole in one). Printed travel time of the ball and plot the path of the balls.
3.Calculated the maximum height and maximum range of the ball for given data.
The distance between the ball and the hole is 100m.
The size of the field is a circle 5m in diameter and the hole is in the middle.
Ф =[15:60] (angle) and Vo =[15:60] initial velocity
I have already written the code for the first part of the task but it stops for me in the second part wher ball fall direct in hole. I try use elseif D == 100 but more than obvious I didn’t tackle it the right way.
v0 = [15:60];
a = [15:60];
g = 9.81;
l = 100;
fprintf('the ball falls on the field in the following cases:\n');
for i = 1:length(v0)
for j = 1:length(a)
D = (v0(i)^2*sind(2*a(j)))/g;
if D>=97.5 && D<=102.5
fprintf('Vo = %.2f m/s | angle = %.2f° | D = %.2f \n',v0(i),a(j), D);
fprintf('HOLE IN ONE! Vo = %.2f m/s | angle = %.2f° | D = %.2f \n',v0(i),a(j), D);