mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 08:03:00 +02:00
9 lines
284 B
Matlab
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
|