Prevent Algebraic Loop Errors in MATLAB Function and Stateflow Blocks

You can use Stateflow charts, MATLAB Function blocks, and Stateflow® Truth Tables in feedback loops in your model. You can also use these blocks with synchronous subsystems enabled by the State Control block. To prevent algebraic loop or synchronous semantic errors, apply these restrictions.

Simulink BlockRestrictions
Stateflow ChartUse Moore charts to prevent an algebraic loop. In the Property Inspector, set the State Machine Type to Moore. Moore charts prevent algebraic loops by ensuring that outputs depend only on current state.
MATLAB Function block

Nondirect feedthrough semantics prevent algebraic loop errors by ensuring that outputs depend only on current state. To enable these semantics, clear the Allow direct feedthrough property check box.

If your block uses direct feedthrough, do not:

  • Call imported functions.

  • Define output function-call events.

  • Define or use persistent variables.

When you apply these restrictions, you allow the Simulink® solver to try to solve the algebraic loop.

Truth Table

Do not:

  • Call imported functions.

  • Define local or output function-call events.

  • Define local or data store memory data.

  • Define or use persistent variables.

  • Use machine-parented data or events.

When you apply these restrictions, you allow the Simulink solver to try to solve the algebraic loop.

See Also

(Stateflow) | (Stateflow)

Related Topics