File Exchange

image thumbnail


version (1.12 KB) by Matthew Kelly
4th-order Runge-Kutta integrator, fully vectorized.


Updated 11 Dec 2015

View License

This is a simple implementation of a 4th-order, fixed-step, Runge-Kutta integrator. It is fully vectorized, which allows a large number of simulations to be carried out in parallel. It is designed to be used inside of optimization code.
% z = rk4(dyn,t,z0)
% This function (rk4) is used to perform a 4th-order Runge-Kutta
% integration of a dynamical system.
% dyn = handle of the form:
% dz = userFunc(t,z)
% t = [1 x nTime] vector of times, created by linspace
% z0 = [nState (x nSim)] matrix of initial states
% z = [nState (x nSim) x nTime ] matrix of trajectories

Cite As

Matthew Kelly (2019). RungeKutta4 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


Added a text function to show usage. Improved description.

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux