MATLAB: Discontinuous ODE . Why solvers dont reduce step size

discontinuousedo

Ive been tryng to solve an edo, but no matter which solver I use ( ode45, ode23, ode113, ode15s, ode23s,…) i ve got a wrong solution. The equation is:
dy = (Qin – Qout) / (pi * Rt ^ 2); Qout = siphon * C * sqrt(2 * g * y(1)) * pi * r ^ 2; Siphon can be 0 or 1. I ve got a solution using a solver with a fixed small step size. My question is: why the solvers were not able to reduce the step size when the variable siphon changes his value? thanks

Best Answer

See http://www.mathworks.com/matlabcentral/answers/59582#answer_72047. Matlab's integrators cannot handle non-smooth functions.
What a pitty that TMW included an example with a linear interpolation in the docs: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3l43b . Not smart.