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

Thomas Petzoldt Thomas.Petzoldt at tu-dresden.de
Wed Jul 16 19:21:07 CEST 2014


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



More information about the R-sig-dynamic-models mailing list