0

i am working with simulink model where i have to launch my simulation for a specific time period. currently i am using

set_param('model_name','StartTime','0','StopTime','5');  
set_param('model_name','SimulationCommand','start');

the problem with this approach is when simulation ends and i start it again, it starts from the beginning and all the simulation progress will lost. here i want to run the simulation from last state.How to do this?

  • what are you doing in-between the steps? Are you changing states of you model? Do you have considered to call all functions directly from Simulink? – Robert Seifert Mar 11 '14 at 07:55
  • i am running it from matlab engine. i run the simulation for specific time period and after it stopped i query some of the workspace variable and repeat the process. – user3346341 Mar 11 '14 at 08:01

1 Answers1

5

You can save the state of your model to relaunch it again from the last state.
Save the state of your model using this command before starting the simulation

set_param('yourModelName','SaveFinalState','on','FinalStateName','myFinalStateVar','SaveCompleteFinalSimState','on')

and before launching the simulation again set the initial state of the model by using the command

set_param('yourModelName','LoadinitialState','on','InitialState','mySimState')

this way you will launch the simulation from exactly last state you left.

bhawesh
  • 1,310
  • 2
  • 19
  • 57