spring_sweep_ode, a MATLAB code which computes a grid of solutions to a parameterized system of ordinary differential equations (ODE) that represent the motion of a spring with mass m, damping b, and stiffness k.

Consider the parameterized second order differential equation:

        m x'' + b x' + k x = 0
which represents the behavior of a spring mass system with a mass of m, a spring constant of k and a damping coefficient b.

We now suppose that we are interested in properties of the solution x(t) over the time interval from 0 to 25 seconds, as we vary the physical properties b and k. In particular, we would like to know the maximum value of x(t) over the time interval for each choice of the physical parameters.

To answer this question, we must solve the ODE for each choice of the parameters.

The basic function has the form:

function peakVals = ode_fun ( bVals, kVals )


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


spring_sweep_ode is available in a MATLAB version and an Octave version and a Python version.

Related Data and Programs:


matlab_ode, MATLAB codes which set up various ordinary differential equations (ODE).

Source Code:

Last revised on 26 April 2021.