Contenuto principale

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 or Priority Mode (External Mode)

  1. Set the execution mode to Run in Kernel mode. In the MATLAB Command Window, type:

    set_param('sldrtex_vdp','RealTimeExecution','kernel')

    Alternatively, you can set the execution mode to Priority mode by using the 'priority' option.

  2. In the MATLAB Command Window, type:

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

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

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

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

See Also

Topics