Add event object to model object
eventObj = addevent(...'
|Required property to specify a trigger condition. Must be a MATLAB® expression
that evaluates to a logical value. Use the keyword |
|Character vector or a cell array of character vectors, each
of which specifies an assignment of the form |
|Property name for an event object from Property Summary.|
|Property value. For more information on property values, see the property reference for each property listed in Property Summary.|
Event object (
and adds the event to the model (
In the event object, this method assigns a value (
to the property
TriggerCondition, assigns a value
EventFcns, and assigns the
model object (
to the property
Parent. In the model object, this
method appends the event object to the property
When the trigger expression in the property
from false to true, the assignments in
executed during simulation.
For details on how events are handled during a simulation, see Events in SimBiology Models.
eventObj = addevent(...' defines
optional properties. The property name and property value pairs can
be any format supported by the function
|Active||Indicate object in use during simulation|
|Name||Specify name of object|
|Notes||HTML text describing SimBiology object|
|Parent||Indicate parent object|
|Tag||Specify label for SimBiology object|
|Type||Display SimBiology object type|
|UserData||Specify data to associate with object|
Add an Event
This example shows how to add an event to a SimBiology model.
Create a simple model with a mass action reaction
A -> B, where A and B are species. Also add the reaction rate parameter, p1, with the parameter value of 0.5.
model = sbiomodel('example'); r1 = addreaction(model,'A -> B'); kl = addkineticlaw(r1,'MassAction'); p1 = addparameter(model,'p1',0.5); kl.ParameterVariableNames = 'p1';
Increase the amount of species A to 100 at time = 2. You can do this by adding an event object to the model. You must specify the event trigger (
time >= 2), and also the event function, which defines what happens when the event is triggered. In this example, the event function is
A = 100.
e1 = addevent(model,'time>=2','A = 100');
Simulate the model, and plot the result.
sd = sbiosimulate(model); sbioplot(sd);
Version HistoryIntroduced in R2007b
R2022a: Component naming restriction
Behavior change in future release
In a future release, there will be a naming restriction on the following model component types: model, compartment, species, parameter, reaction, rule, event, observable, dose, and variant. The restriction is that within a single model, these components will be required to have unique names even when they are of different types with the following two exceptions:
Species in different parent compartments can have the same name.
Parameters with different parents can have the same name. Specifically, you can use the same name for a model-scoped parameter and reaction-scoped parameters, where each reaction-scoped parameter belongs to a different reaction.