I have to model a projectile for some work for school (by solving an ode). I have successfully done so using Euler's methods, but am also required to solve them using the Runge Kutta method. This is where I run into a problem. The derived 4th order Runge Kutta method requires that the inputs for your function of acceleration look something like this FUNCTION(time increment,distance,velocity), my function for acceleration however is more like FUNCTION(time increment, velocityx , velocityy). I work out the distance traveled by the projectile afterwards. this works fine for Euler's but not for the Runge Kutta method. Is there a derivation of it that would allow me to calculate it with the inputs I have?
This is my code for the runge kutta method:
% Move the problem one step forward in time using Runge Kutta
function [x, xd, xdd] = oneStepRungeKutta(t, x, xd, tInc)
%Calculate current acceleration
xdd = acceleration(t, x, xd);
%Calculate next displacement and velocity
x = x + tInc*(xd+(1/3)*(A+B+C));
xd = xd + (1/3)*(A+2*B+2*C+D);
but it requires my acceleration funtion to be in the form of FN(t,x,xd) and I want it to be in the form of FN(t,xd,xy). Is this even possible?
This might not make any sense! If that is the case, I'm sorry. Its probably that try as I might I cannot get my head around the Runge Kutta method. Any help or input would be greatly appreciated.