From: Alex on
Hello,

I've developed a model using the ODE45 solver. It worked fine, but now the solver has difficulties with a switching variable. I used this variable from the beginning and had no difficulties with it before. Here is a simplified summary of what happens:

if Y1 < Y2 then R = x, else R = y
dV1dt = Y3*C + Y2/R - Y1/((R+C)/2)

Thus the only switching variable is R, and this seems to make the model unstable. However, this R is very crucial for the model. How can I solve this instability?