MATLAB: How to change solver’s start and stop time in Simulink through a variable

simulinksolverstarttimestoptime

How do I change solver's start and stop time in Simulink through a variable in MATLAB? I am using this command-
set_param(ModelName,'stopTime','SimStopTime')
but I am getting an error-
>> set_param(ModelName,'stopTime','SimStopTime')
Invalid Simulink object name: DummyModel3
Where DummyModel3 is my Simulink model. Any idea how to fix this?

Best Answer

The Simulink ModelName must be opened when you run these lines of code. Try this
open(ModelName)
set_param(ModelName,'StopTime','SimStopTime')
Related Question