Question

I want to plot one half, the positive increasing half, of a projectile motion passing through a specified coordinate on the y axis say till the apex of the midpoint or mean of the motion.For example, by specifying the coordinates starting from (0,0) to (1000,150) and only the positive half of the curve is plotted since the other half will be symmetric. The apex of the first half of the curve touches at (1000,150). Can somebody please post the code for that.Thank you.

Was it helpful?

Solution

So you're looking for a quadratic curve

h(t) = a + b t + c t^2

Such that it goes through the points (0,0) and (x,y):

0 = a                 #  ->  a = 0
y = a + b x  + c x^2  #  ->  y = x (b + c x)

You also want the slope of the curve

h'(t) = b + 2 c t

to be zero at the apex (x,y)

0 = b + 2 c x         #  ->  b = -2 c x

Hence you have

y = x (-2 c x + c x)  #  ->  c = -y / x^2

So the code you want is

x = 1000;
y = 150;
a = 0;
c = -y/x^2;
b = -2*c*x;

t = 0:x;
h = a + b*t + c*t.^2;

plot(t,h)
grid

Which gives you this plot:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top