Main Content

Instrument a Stateflow Subsystem

A Simulink® Real-Time™ model that uses Stateflow® blocks can provide visual confirmation that your chart behaves as expected when you simulate the model or run the real-time application.

  1. This procedure uses the model slrt_ex_sf_car. To open the model and its related MAT file, in the MATLAB Command Window, type:

    open_system(fullfile(matlabroot, 'toolbox', 'slrealtime', ...
        'examples', 'slrt_ex_sf_car'))
    load(fullfile(matlabroot, 'toolbox', 'slrealtime', ...
        'examples', 'slrt_ex_user_inputs.mat'),'-mat')
  2. To make Stateflow states available in the Simulation Data Inspector, select them and mark them for Log Self Activity.

  3. Open the slrt_ex_sf_car model.

  4. Double-click the shift_logic chart.

    Image of slrt_ex_sf_car charl log of self activity

  5. In the gear_state chart, select the first state

  6. Click the Log Self Activity button and the Test Point button.

  7. Repeat listitems 3–4 for gear_state values second, third, and fourth.

  8. Build and download the real-time application to the target computer. On the Real-Time tab, click Run on Target.

  9. Monitor Stateflow states by using the Simulation Data Inspector. For more information, see View Data in the Simulation Data Inspector and View State Activity by Using the Simulation Data Inspector (Stateflow).

Related Topics