In: Computer Science
question 1 (explain each code)
If more information if needed please let me know
a)t=linspace(0,1,1000); % Time t
Meaning:
b) for i=1:1000
xt(i)=v*cos(theta*pi/180)*t(i);
yt(i)=h+(v*sin(theta*pi/180)*t(i))-0.5*g*t(i)^2;
end
Meaning:
c) k = find(yt<0,1) % find index at which distance becomes
fprintf('Ball hits the ground at distance of %d meters',xt(k))
Meaning:
d) x=0:0.1:max(xt);
y=0;
plot(x,y*ones(size(x)),'--k')
Meaning: