How to set Simulink start time / stop time programatically

You can set the start time and stop time of a Simulink model programmatically using the set_param function in MATLAB. Here’s how you can do it:

set_param(gcs, 'StartTime', '1.5')
set_param(gcs, 'StopTime', 'inf')

This code sets the start time to 1.5 seconds and the stop time to infinity for the currently selected Simulink model (gcs stands for “get current system” and will return the name for the currently loaded simulink model).