MATLAB: Triggering Events In SimBiology toolbox

eventsSimBiologytrigger

I am wondering if it's possible to define time delay as an event for a trigger in simbiology. I want to define a duration of 2 hours for one stage of the system. For example, when species_1 gets a certain value (like species_1 == 5), I need the system to stay in this state for 2 hours and afterwards species_1 =0 and species_2 = 1 (while some other species are interacting with each other independent of this process). I defined a function as event and used "tic toc" to make a delay after trigger, but even though this provides a delay, the amount of corresponding species are changed at the beginning of delay not at the end! Can somebody help me with this? thanks

Best Answer

I have attached a .zip file which contains a .sbproj file with a small example. In this example species_1 is created with constant rate, than you have reversible reaction which creates species_2 and species_2 degenerated with constant rate. I have then also created a copy of this whole set. This copy should not be effected by stages while the species_1 and species_2 are.
The two stages are modelled using two events: The first event gets triggered if species_1 gets above a certain threshold. During a simulation it is unlikely that for example 5 is exactly hit, hence one uses >5. Then you have several event functions:
  • stage is used to ensure that the second event triggers at the correct time
  • stage_start_time stores the time the event is triggered. This is needed to calculate the time the second event should be started at the stage_start_time + the time the first stage takes
  • In order to keep species_1 and species_2 on there values you have to set the generating and removing kinetics to 0
  • The trigger for the second event is that stage=1 (meaning the first stage took place) and that the time is past stage_start_time+the time the first stage takes
Is this explanation understandable?