Consider you want to simulate any (stochastic) nonlinear dynamics with/without time delay in MATLAB scripts. The main question here is how to save the time of the events and write the triggering condition in MATLAB using the current and the triggered time (tk).