Main Content

Run Application fromMATLABCommand 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 modelsldrtex_model. To open this model, in the MATLAB Command Window, type:

open_system(docpath(fullfile(docroot,'toolbox',...'sldrt','examples','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. 预计到达rt 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. 预计到达rt 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')
    模型sldrtex_model加载
  3. 预计到达rt 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