This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.
method

Method to use during resampling. It can be one of the following:

  • 'interp1q' — Uses the interp1q function.

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

    • 'nearest'

    • 'linear'

    • 'spline'

    • 'pchip'

    • 'cubic'

    • 'v5cubic'

  • 'zoh' — specifies zero-order hold.

You can also specify the method as a string using double quotes, such as "pchip".

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

Introduced in R2007b