MATLAB: How to limit the solution of an ode

modelode

For example, if I want the dynamics of a tank that is been filled with liquid, the level will be limited by zero and the tank diameter.
To control the nonnegative case, we can use options = odeset( 'NonNegative',1), so that the level never goes under zero.
However, how to limit the level in its maximum (tank diameter)?

Best Answer

Add the algebraic equation
y-(diameter-level(t))=0
and apply the non-negative option to the unknown y.
Best wishes
Torsten.
Related Question