DISTINCTION TASK 1 Dtask1_f.m function distance =Dtask1_f(v,theta) g=9.81; A=0:0.001:10; distance=[]; for s=1:length(A) y=1.5+v*A(s)*sind(theta)-0.5*g*(A(s)^2); if(y<=0) distance(1)=v*A(s)*cosd(theta); break; end end if(isempty(distance)) disp('Warning ball doesn''t hit the ground') distance(1)=NaN; end
Dtask1.m theta=0:0.01:60; for s=1:length(theta) d(s)=Dtask1_f(4,theta(s)); end plot(theta,d); legend('v=4m/s'); title('Distance of ball thrown as a function of angle'); xlabel('Initial angle(deg)'); ylabel('Distance thrown(m)');
MUKARAM HUSSAIN
101219797
DISTINCTION TASK 1
MUKARAM HUSSAIN
101219797