WUT_Computer_Science/ENUME/projectC/rk4phi.m
2022-01-07 19:37:20 +01:00

9 lines
284 B
Matlab

% calculate the phi for RK4 algorithms
function phi = rk4phi(fun, stepval, stepsize)
k1 = fun(stepval);
k2 = fun(stepval + 0.5 * stepsize * k1);
k3 = fun(stepval + 0.5 * stepsize * k2);
k4 = fun(stepval + stepsize * k3);
phi = (k1 + 2 * k2 + 2 * k3 + k4) / 6;
end