Skip to content

[R-sig-dyn-mod] different event functions at different times in a compiled code

3 messages · Omari Mohamed, Thomas Petzoldt

#
Hi Mohamed,

the easiest way is to write an event function that can handle both cases:

void eventfun(int *n, double *t, double *y) {

   if (*t < 150)
     y[0] =   1.5 * y[0];
   else
     y[1] = 1.001 * y[1];
}



There was also a related thread how to do something similar in R:

https://stat.ethz.ch/pipermail/r-sig-dynamic-models/2013q1/000159.html


In any case, please think about whether you really need events for this,
or if forcing functions would be the more appropriate modelling approach.

Hope it helps

Thomas