Main Content

Prevent Algebraic Loop Errors in MATLAB Function, Chart, and Truth Table Blocks

You can use MATLAB Function, Chart, and Truth Table blocks in feedback loops in your model if you apply certain settings. 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.

BlockRestrictions
Chart (Stateflow)

Use 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 the current state.

MATLAB Function

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

When Allow direct feedthrough is selected, do not:

  • Call imported functions.

  • Define output function-call events.

  • Define or use persistent variables.

When you follow these guidelines, you allow the Simulink® solver to try to solve resultant algebraic loops.

Truth Table (Stateflow)

Do not:

  • Call imported functions.

  • Define local or output function-call events.

  • Define local or data store memory data.

  • Define or use persistent variables.

When you follow these guidelines, you allow the Simulink solver to try to solve resultant algebraic loops.

Related Topics