MATLAB: Changing the simulation time in simulink through script

MATLABsimulink

I am controlling my simulink models through MATLAB Script ,and am updating stop time through script,,,The problem here am getting is if i change any parameters value of the simulink while simulink is running,,the simulation calculation is con sidering the changed values from the initial step of the simulation,,,but rather i want my simulation to consider the new parameter value value from the step i chanf=ged while simulation is running

Best Answer

I am not sure how you are managing to change the simulation time during simulation.
But for your parameter value problem :
Simulink evaluates all the parameters values before the start of simulation. See first step of Model compilation.
If you change any parameter during simulation, simulink will not notice it. To tell the simulink to re-calculate the parameters/interfaces, you have to give update command.
After you change the parameter value from scrip, give command
set_param('YourModel', 'SimulationCommand', 'update')