MATLAB: How to find the last possible minimum

fminconMATLABsimulink

For a school project, I have modeled a zipline in Simulink, and am trying to determine the last possible moment I can begin braking and still achieve a velocity of zero at the end of the line.
I know the length of the line, and I know my velocity at each point. I am trying to use fmincon, with the function minimizing the (final velocity)^2.
However, if I brake too soon, my final velocity is also zero.
How can I get Matlab to solve for the last possible location that I can apply the brakes to get a velocity of zero?

Best Answer

Add the remaining distance to the output of the function you are minimizing. The combination cannot minimize unless both distance and velocity are 0.