This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

na_0006: Guidelines for mixed use of Simulink and Stateflow

ID: Title

na_0006: Guidelines for mixed use of Simulink and Stateflow

Priority

Strongly recommended

Scope

MAAB

MATLAB Versions

All

Prerequisites

None

Description

The choice of whether to use Simulink or Stateflow to model a given portion of the control algorithm functionality should be driven by the nature of the behavior being modeled.

  • If the function primarily involves complicated logical operations, use Stateflow diagrams.

    Use Stateflow diagrams to implement modal logic, where the control function to be performed at the current time depends on a combination of past and present logical conditions.

  • If the function primarily involves numerical operations, use Simulink features.

Specifics

  • If the primary nature of the function is logical, but some simple numerical calculations are done to support the logic, implement the simple numerical functions using the Stateflow action language.

  • If the primary nature of the function is numeric, but some simple logical operations are done to support the arithmetic, implement the simple logical functions with Simulink blocks.

  • If the primary nature of the function is logical, and some complicated numerical calculations must be done to support the logic, use a Simulink subsystem to implement the numerical calculations. The Stateflow software should invoke the execution of the subsystem, using a function call.

  • Use the Stateflow product to implement modal logic, where the control function to be performed at the current time depends on a combination of past and present logical conditions. (If there is a need to store the result of a logical condition test in a Simulink model, for example, by storing a flag, this is an indicator of the presence of modal logic, which should be modeled with Stateflow software.)

    Incorrect

    Correct

  • Use Simulink to implement numerical expressions containing continuously-valued states, such as: difference equations, integrals, derivatives, and filters.

    Incorrect

    Correct

Rationale

  • Readability

  • Workflow

  • Simulation

  • Verification and Validation

  • Code Generation

Last Changed

V2.0

Model Advisor Check

Not applicable

Introduced in R2010a