MATLAB: Controlling the Simulink model run status through external API

simulinksimulink coderSimulink Desktop Real-Timevisual studio

RTWT workshop is used to generate C code for a Simulink model and start/ stop of the model is controlled through a VC++ GUI (Visula studio 2008) using set_param() commands. This is working fine. But when it is desired to pause the model execution using a similar method (set_param(‘modelname’,’SimulationCommand’,’pause’)), we find that the model does not pause. We have also tried using a assertion block, but of no use. We wanted to know the conditions in which any model cannot be paused (because we have tried the same in a very simple simulink model and it works).

Best Answer

Code running in real time generally cannot be paused. That would contradict its purpose to run in real time. For example, if the code controls an externally connected device, pausing the code would get the control algorithm out of sync with the device state. After resuming the paused code the results will be unpredictable.
Please be more specific about what you are trying to achieve by pausing real-time code. Most likely, there are other ways to get the desired effect.