f

#### Solving an ODE using RungeKutta methods.

```Hey,

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
A=(tInc/2)*(acceleration(t,x,xd));
Beta=(tInc/2)*(xd+A/2);
B=(tInc/2)*(acceleration(t+tInc/2,x+Beta,xd+A));
C=(tInc/2)*(acceleration(t+tInc/2,x+Beta,xd+B));
Delta=tInc*(xd+C);
D=(tInc/2)*(acceleration(t+tInc,x+Delta,xd+2*C));
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.

Thanks!
```
 0
Francisco
12/5/2010 7:17:05 AM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader.

0 Replies
1545 Views

Similar Articles

[PageSpeed] 43