MATLAB: Stop simulation in Matlab Fctn block

MATLABsimulinkstop execution of matlab fctn block

How can I stop simulation inside the ML Fctn block before it reach the end of the simulation time?
Thanks.

Best Answer

Use the Stop Simulation block. When the input for the block (e.g. output of your MATLAB Function block) goes to non-zero, the sim stops.