MATLAB: How to access simulation information with the command SIM in Simulink 7.3 (R2009a)

informationsimsimulink

I would like to start my simulation with the command SIM in the MATLAB command window. Now I would like to obtain information during runtime like the actual simulation time. Is this possible when using the SIM command?

Best Answer

The ability to obtain information about the current simulation when using SIM is not available in Simulink 7.3 (R2009a).
This is because the SIM command blocks the MATLAB command window and other commands cannot be executed until the SIM command has completed execution. The advantage is that you can use this for MATLAB-script automation of data processing.
To work around this issue you can use the SET_PARAM command to start/stop your simulation:
set_param(<modelname>,'SimulationCommand','start')
More information can be found at:
<http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/f23-7515.html>
This does not block the MATLAB command window and you can retrieve all the needed information of the current simulation.
MATLAB-file automation: Here you need to check the state of the simulation because the command line is not blocked.