MATLAB: A ramp block going backwards

simulink

Hey people!
I am using a ramp block in Simulink driven into an m-function. I am checking the signal every time the m-function is executed and sometimes the ramp value is decreasing.
How can be this possible?
Many thanks.

Best Answer

You are probably using a variable step solver. Variable step solvers often need to take steps backward to ensure they respect the specified tolerance.