MATLAB: Simulation control in m-file

m-filesimsimulink

'sim' command is usually used for handling simulink in m-file.
I want to pause the sim when some conditon is matched, is it possible using 'sim' command in m-file? If not, is there no way to do that?

Best Answer

set_param('ModelName', 'SimulationCommand', 'start')
set_param('ModelName', 'SimulationCommand', 'stop')
set_param('ModelName', 'SimulationCommand', 'pause') <- Pause simulation
set_param('ModelName', 'SimulationCommand', 'continue')
set_param('ModelName', 'SimulationCommand', 'update')