addevent (model)

Add event object to model object

Syntax

eventObj = addevent(modelObj, 'TriggerValue', 'EventFcnsValue')

eventObj = addevent(...'PropertyName', PropertyValue...)

Arguments

modelObjModel object.
TriggerValueRequired property to specify a trigger condition. Must be a MATLAB® expression that evaluates to a logical value. Use the keyword 'time' to specify that an event occurs at a specific time during the simulation. For more information, see Trigger.
EventFcnsValueA string or a cell array of strings, each of which specifies an assignment of the form 'objectname = expression', where objectname is the name of a valid object. Defines what occurs when the event is triggered. For more information, see EventFcns.
PropertyNameProperty name for an event object from Property Summary.
PropertyValueProperty value. For more information on property values, see the property reference for each property listed in Property Summary.

Description

eventObj = addevent(modelObj, 'TriggerValue', 'EventFcnsValue') creates an event object (eventObj) and adds the event to the model (modelObj). In the event object, this method assigns a value (TriggerValue) to the property TriggerCondition, assigns a value (EventFcnsValue) to the property EventFcns, and assigns the model object (modelObj) to the property Parent. In the model object, this method appends the event object to the property Events.

When the trigger expression in the property Trigger changes from false to true, the assignments in EventFcns are executed during simulation.

For details on how events are handled during a simulation, see Event Object.


eventObj = addevent(...'PropertyName', PropertyValue...)
defines optional properties. The property name and property value pairs can be any format supported by the function set (for example, name-value string pairs, structures, and name-value cell array pairs).

You can view additional object properties with the get command. You can modify additional object properties with the set command. To view events of a model object (modelObj), use the command get(modelObj, 'Events').

Method Summary

copyobj (any object)Copy SimBiology object and its children
delete (any object)Delete SimBiology object
display (any object)Display summary of SimBiology object
get (any object)Get object properties
set (any object)Set object properties

Property Summary

ActiveIndicate object in use during simulation
EventFcnsEvent expression
NameSpecify name of object
NotesHTML text describing SimBiology object
ParentIndicate parent object
TagSpecify label for SimBiology object
TriggerEvent trigger
TypeDisplay SimBiology object type
UserDataSpecify data to associate with object

Examples

  1. Create a model object, and then add an event object.

    modelObj = sbmlimport('oscillator')
    eventObj = addevent(modelObj, 'time>= 5', 'OpC = 200');
  2. Get a list of properties for an event object.

    get(modelObj.Events(1));
    

    Or

    get(eventObj)

    MATLAB displays a list of event properties.

                Active: 1
            Annotation: ''
             EventFcns: {'OpC = 200'}
                  Name: ''
                 Notes: ''
                Parent: [1x1 SimBiology.Model]
                   Tag: ''
               Trigger: 'time >= 5'
                  Type: 'event'
              UserData: []

See Also

Event object

Was this topic helpful?