MATLAB: How to run simulink model from gui written in script

guiMATLABsimulink

I am running my simulink models from GUI,where Gui i have developed using MATLAB script,,,,and am controlling my stop time of both models through script ,,but am unable to do this,, Getting error like""""""Error using FinalTest/pushbutton2_Callback (line 115) Invalid StopTime specified in the Configuration Parameters dialog for block diagram 'course_speed_position'
Error while evaluating uicontrol Callback"""""This is my error ,,anybody help me?

Best Answer

Try this, set_param() expect the value in string. So convert the value of i to string then pass it to set_param().
for i=1:25
set_param('course_speed_position','StopTime', sprintf('%d',i));
end