Euler's method on the trajectory equation

sba

New member
Joined
Nov 19, 2017
Messages
2
The problem is to use Euler's method to calculate the trajectory of a projectile, assuming no forces other than gravity with initial speed V and angle θ, with x and y being 0 at t=0 and then to plot this using Matlab. However I think my problem is in my understanding of the ideas behind Euler's method.

I was using:

. . . . .yn+1 = yn + hf(yn, tn)

with f(yn, tn) equal to the derivative of the trajectory equation with respect to x, which I made to be:

. . . . . y'=tanθ - gx / V^2 * Cos(θ)^2

However this leaves me with three variables which I'm not sure how to work around so I tried doing it separately for x and y with respect to t.

So from:

. . . . . y= Vtsin(θ) - 1/2gt^2 and x=Vtcos(θ)

I got:

. . . . . dy/dt = Vsin(θ) - gt and dx/dt = Vcos(θ)

I can then do Euler's method for x using:

. . . . .x1 = x0 + hVcos(θ) where x0=0

but for y I get:

. . . . .y1 = y0 +h(Vsin(θ)-gt) where y0=0

I don't understand what I am meant to substitute in for t each time I calculate y. h is my timestep so could I just replace t with h? I'm doing this in Matlab so for each calculation I could just add a little bit to h. And then after that I think I just need to plot each xn against yn in Matlab?
 
Last edited by a moderator:
Top