Main Content

simulate

Simulate exported SimBiology model

Description

[t,x,names] = simulate(model) simulates a model, using the default initial values specified by model.InitialValues (which are always equal to the InitialValue property on the corresponding ValueInfo object). simulate returns:

  • t, time samples.

  • x, simulation data that contain variation in the quantity of states over time.

  • names, column labels of simulation data x.

You can set additional simulation options using the property SimBiology.export.Model.SimulationOptions.

example

[t,x,names] = simulate(model,initialValues) simulates a model, using the values specified in initialValues as the initial values of the simulation.

[t,x,names] = simulate(model,initialValues,doses) simulates the model, using the specified initial values and doses.

simDataObj = simulate(___) returns simulation data in a SimData object simDataObj using any of the input arguments in the previous syntaxes. The simDataObj contains time and state data, as well as metadata, such as the types and names for the reported states. You can access the time, data, and names stores in simDataObj using the properties simDataObj.Time, simDataObj.Data, and simDataObj.DataNames, respectively.

Examples

collapse all

Load a sample SimBiology model (lotka), and select the species y1 and y2 for simulation.

modelObj = sbmlimport('lotka');
modelObj.getconfigset.RuntimeOptions.StatesToLog = ...
       sbioselect(modelObj,'Name',{'y1','y2'});

Export the model object.

em = export(modelObj);

Simulate the exported model.

[t,y] = simulate(em);
figure
plot(t,y)

Figure contains an axes object. The axes object contains 2 objects of type line.

Modify the initial conditions, and simulate again.

xIndex = em.getIndex('x');
em.InitialValues(xIndex) = em.InitialValues(xIndex)*1.1;
[t,y] = simulate(em);
figure
plot(t,y)

Figure contains an axes object. The axes object contains 2 objects of type line.

Input Arguments

collapse all

Input model, specified as a SimBiology.export.Model object.

Initial values of the simulation, specified as a vector of values for simulate to use. initialValues must have the same number of elements as model.InitialValues. If you do not specify initialValues, then simulate uses values specified in model.InitialValues.

Doses used for simulation, specified as a vector of dose objects. The input dose objects must be a subset of the doses in the exported model, as returned by getdose. If you do not specify doses, then simulate uses all dose objects in the exported model.

Output Arguments

collapse all

Time samples, returned as an n-by-1 vector of time samples from the simulation, where n is the number of time samples.

Simulation data, returned as an n-by-m matrix, where n is the number of time samples and m is the number of states logged during the simulation. Each column of x describes the variation in the quantity of a state over time.

Names labelling the simulation data, returned as an m-by-1 cell array of character vectors with names labeling the rows and columns of x, respectively.

Simulation data, returned as a SimData object containing simulation time and state data, as well as metadata, such as the types and names for the reported states.

Version History

Introduced in R2012b