MATLAB: How to pause and resume the simulation at specified time intervals in Simulink 7.8 (R2011b)

simulink

I would like to execute a discrete simulation step of a simulink model from an M-File. The discrete step size of the simulink model is smaller than the time intervals I want to read and update values out of the model from an M-File. E.g. Ts=0.01 and I would like to pause the simulation at t=0.1 intervals and evaluate yout and update some block vlues. Then the simulation should resume for another 0.1s and so on. How can I do this?

Best Answer

You can do this by using an Interpreted MATLAB Function block with the set_param command inside the function. If you run the attached model, you will notice that it stops at every 10th simulation step (this is maintained by the counter). You may look at the data and resume simulation by pressing the play button, or by executing the Play Simulation command at the MATLAB Command Window.