Main Content

Run Application from MATLAB Command Line

You can use the MATLAB® command-line interface as an alternative to using the Simulink® UI. Enter commands directly in the MATLAB Command Window or save them in a script file.

After you build the real-time application, you can run your model in real time.

This procedure uses the model sldrtex_model. To open this model, in the MATLAB Command Window, type:

openExample('sldrtex_model')

It assumes that you have already created a real-time application from that model.

Connected IO Mode (Normal Mode)

  1. In the MATLAB Command Window, type:

    set_param(gcs,'SimulationMode','normal')
    
  2. To start running the simulation, type:

    set_param(gcs,'SimulationCommand','start')
    
  3. To stop running the simulation, type:

    set_param(gcs,'SimulationCommand','stop')
    

Accelerator Mode

  1. In the MATLAB Command Window, type:

    set_param(gcs,'SimulationMode','accelerator')
    
  2. To start running the simulation, type:

    set_param(gcs,'SimulationCommand','start')
    
  3. To stop running the simulation, type:

    set_param(gcs,'SimulationCommand','stop')
    

Run in Kernel Mode (External Mode)

  1. In the MATLAB Command Window, type:

    set_param(gcs,'SimulationMode','external')
    
  2. To load the real-time application and connect it to the Simulink block diagram, type:

    set_param(gcs,'SimulationCommand','connect')
    
    Model sldrtex_model loaded
    
  3. To start running the real-time application, type:

    set_param(gcs,'SimulationCommand','start')
    
  4. To stop the real-time application, type:

    set_param(gcs,'SimulationCommand','stop')
    

Related Topics