Problem 2 (explain each codes please)
If more information if needed please let me know
1) % time vector
t=linspace(0,1,1000);
x = zeros(size(t));
y = zeros(size(t));
Meaning:
3)% loop to find the value of x and y for different values of time
for i=1:length(t)
x(i) = v*cos(angle_theta)*t(i);
y(i) = h+v*sin(angle_theta)*t(i)-(0.5*g*(t(i).^2));
end
Meaning:
4)% find the first index where y<=0 i.e the ball hits the ground
I = find(y<=0,1);
fprintf('The ball hits the ground at distance of %f meters\n',x(I));
Meaning:
5) plot(x,zeros(size(t)),'k--');
Meaning:
Get Answers For Free
Most questions answered within 1 hours.