How do you utilise the Runge Kutta method to calculate displacement and velocity from acceleration?

479 Views Asked by At

I'm currently trying to make a script in MatLab that, given the acceleration formula, returns the velocity and displacement over time.

I have the following:

$\frac{dv}{dt} = g - C * |v| * v -max(0, K(y - L))$

where:

$H = 74m, D = 31m, C = 0.9/m, m = 80kg, L = 25m, K = 90/m, g = 9.8m/s^2$

The question is in relation to a bungee jump model. L refers to the length of the rope, y is the displacement from the platform, where y = 0 = the platform, and it increases when falling. K is the spring constant of the rope, and C is the drag.

How do I utilise Runge Kutta to determine the velocity and displacement from the above acceleration formula?

1

There are 1 best solutions below

0
On

You have to convert this second order equation into a first order system

function du = derivs(t,u)
% u = [y v]
du = [ v  g-C∗abs(v)∗v-max(0,K*(y−L)) ]

Then call any ODE solver like ode45, or ode4 from this tutorial for the classical RK4 method.

[t, u] = ode45(@derivs, [0 20], [0 0])

or

t0=0; tfinal=20; h=0.1;
t=t0:h:tfinal;
u=ode4(@derivs,t0,h,tfinal,[0 0])