resample (SimData)

Resample SimData object array onto new time vector

Syntax

newSimDataObj = resample(simDataObj)
newSimDataObj = resample(simDataObj, timevector)
newSimDataObj = resample(simDataObj, timevector, method)

Arguments

newSimDataObjResampled SimData object array.
simDataObjSimData object array that you want to resample.
timevectorReal numeric array of time points onto which you want to resample the data.
methodMethod to use during resampling. Can be one of the following:

  • 'interp1q' — Uses the MATLAB® function interp1q.

  • — To use the MATLAB function interp1, specify one of the following methods:

    • 'nearest'

    • 'linear'

    • 'spline'

    • 'pchip'

    • 'cubic'

    • 'v5cubic'

  • 'zoh' — specifies zero-order hold.

    Warning:   Note that 'cubic' method will change in a future release. Use 'pchip' instead.

Description

newSimDataObj = resample(simDataObj) resamples the simulation data contained in every element of the SimData object array simDataObj onto a common time vector, producing a new SimData array newSimDataObj. By default, the common time vector is taken from the element of simDataObj with the earliest stopping time.

newSimDataObj = resample(simDataObj, timevector) resamples the SimData array simDataObj onto the time vector timevector. timevector must either be a real numeric array or the empty array []. If you use an empty array, resample uses the default time vector as described above.

newSimDataObj = resample(simDataObj, timevector, method) uses the interpolation method specified in method.

If the specified timevector includes time points outside the time interval encompassed by one or more SimData objects in simDataObj, the resampling will involve extrapolation and you will see a warning. See the help for the MATLAB function corresponding to the interpolation method in use for information on how the function performs the extrapolation.

Examples

Simulating and Resampling Data

  1. The project file, radiodecay.sbproj contains a model stored in a variable called m1. Load m1 into the MATLAB workspace.

    sbioloadproject('radiodecay');
    simDataObj = sbiosimulate(m1);
    
  2. Resample the data.

    newSimDataObj = resample(simDataObj, [1:5], 'linear');

Resampling Data for Ensemble Runs

  1. The project file, radiodecay.sbproj, contains a model stored in a variable called m1. Load m1 into the MATLAB workspace.

    sbioloadproject('radiodecay');
    
  2. Change the solver to use during the simulation and perform an ensemble run.

    csObj  = getconfigset(m1);
    set(csObj, 'SolverType', 'ssa');
    simDataObj = sbioensemblerun(m1, 10);
  3. Interpolate the time steps.

    newSimDataObj = resample(simDataObj, [1:10], 'linear');
  4. View the time steps in the SimData object arrays.

    newSimDataObj(1).Time
    simDataObj(1).Time
Was this topic helpful?