I want some help in my Projectile motion function where i can launch my projectile from a platform above x-axis and Still hit the ground Thanks in advance.
function [range,maxh,xmaxh]= projectilemotion1(x0,y0,v0,angle,g)% inputs
% x0 = Initial x value (starting distance)
% y0 = Initial y value (starting height)
% v0 = Initial velocity
% angle = angle of projectile
% g=gravitational acceleration
% outputs
% range = maximum distance
% maxh = max height
% xmaxh = x co-ordinate at the highest point
range = (v0.^2)./g * sind(2*angle); xstep = range ./150; x = x0:xstep:range; y = (x*tand(angle) - g /(2*(v0.^2)*(cosd(angle)).^2)*x.^2)+y0; for i=1:length(x) h=plot(x(i),y(i),'.'); set(h,'LineWidth',2); xlabel('Distance (Meters)'); ylabel('Height (Meters)'); hold on pause(0.001);endzoom on;maxh = max(y)xmaxh = (v0.^2)./(2*g)*sind(2*angle)Time = sqrt(2*maxh)./gh=plot(xmaxh,maxh,'g.');set(h,'MarkerSize',20);end
Best Answer