Documentation

getdata (SimData)

Get data from SimData object array

Syntax

[t, x, names] = getdata(simDataObj)
[Out] = getdata(simDataObj, 'FormatValue')

Arguments

Output Arguments

tAn n-by-1 vector of time points.
xAn n-by-m data array. t and names label the rows and columns of x respectively.
namesAn m-by-1 cell array of names.
MetadataWhen used with the 'nummetadata' input argument, Metadata contains a cell array of metadata structures. The elements of Metadata label the columns of x.
OutData returned in the format specified in 'FormatValue', shown in Input Arguments. Depending on the specified 'FormatValue', Out contains one of the following:
  • Structure array

  • SimData object

  • Time series object

  • Combined time series object from an array of SimData objects

Input Arguments

simDataObjSimData object. Enter a variable name for a SimData object.
FormatValue

Choose a format from the following table.

FormatValueDescription
'num'Specifies the format that lets you return data in numeric arrays. This is the default when getdata is called with multiple output arguments.
'nummetadata'Specifies the format that lets you return a cell array of metadata structures in metadata instead of names. The elements of metadata label the columns of x.
'numqualnames'Specifies the format that lets you return qualified names in names to resolve ambiguities.
'struct'Specifies the format that lets you return a structure array holding both data and metadata. This is the default when you use a single output argument.
'simdata'Specifies the format that lets you return data in a new SimData object. This format is more useful for SimData methods other than getdata.
'ts'Specifies the format that lets you return data in time series objects, creating an individual time series for each state or column and SimData object in simDataObj.
'tslumped'Specifies the format that lets you return data in time series objects, combining data from each SimData object into a single time series.

Description

[t, x, names] = getdata(simDataObj) gets simulation time and state data from the SimData object simDataObj. When simDataObj contains more than one element, the outputs t, x, names are cell arrays in which each cell contains data for the corresponding element of simDataObj.

[Out] = getdata(simDataObj, 'FormatValue') returns the data in the specified format. Valid formats are listed in Input Arguments.

Examples

Simulating and Retrieving Data

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

    sbioloadproject('radiodecay');
    simDataObj = sbiosimulate(m1);
    
  2. Get all the simulation data from the SimData object.

    [t x names] = getdata(simDataObj);

Retrieving 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. Get all the simulation data from the SimData object.

    tsObjs = getdata(simDataObj(1:5), 'ts');
Was this topic helpful?