MATLAB: How to run the Real-Time Windows Target simulation from the command line or a MATLAB file

commandlinem-filerealrtwrunscripttargettimewindows

I would like to run my Real-Time Windows Target simulation from the command line or a MATLAB file.

Best Answer

You can use the SET_PARAM function to connect and simulate your target model from the MATLAB command line or a MATLAB file. See the following example for the steps necessary to simulate your model:
1. First, you need to change the simulation mode of a model from 'normal' to 'external'. You can do this with the following command:
 
set_param('model_name','SimulationMode','external')
2. Second, you need to connect to the target. You can do this with the following command:
 
set_param('model_name','SimulationCommand','connect');
3. Now, you need to run the code:
 
set_param('model_name','SimulationCommand','start');
4. To stop the real time code:
 
set_param('model_name','SimulationCommand','stop');
5. And finally, to disconnect from the target:
 
set_param('model_name','SimulationCommand','disconnect');
For more information on simulating from the command line, please refer to the Simulink User's Guide.