Using Simulink | ![]() ![]() |
Avoiding Invalid Loops
Simulink allows you to connect the output of a block directly or indirectly (i.e., via other blocks) to its input, thereby, creating a loop. Loops can be very useful. For example, you can use loops to solve differential equations diagramatically (see Modeling a Simple Continuous System) or model feedback control systems. However, it is also possible to create loops that cannot be simulated. Common types of invalid loops include:
The Subsystem Examples block library in the Ports & Subsystems library contains models that illustrates examples of valid and invalid loops involving triggered and function-call subsystems. Examples of invalid loops include the following models:
simulink/Ports&Subsystems/sl_subsys_semantics/Triggered subsystem/sl_subsys_trigerr1
simulink/Ports&Subsystems/sl_subsys_semantics/Triggered subsystem/sl_subsys_trigerr2
simulink/Ports&Subsystems/sl_subsys_semantics/Function-call systems/sl_subsys_fcncallerr3
You might find it useful to study these examples to avoid creating invalid loops in your own models.
Detecting Invalid Loops
To detect whether your model contains invalid loops, select Update diagram from the model's Edit menu. If the model contains invalid loops, Simulink highlights the loops
and displays an error message in the Simulink Diagnostic Viewer.
![]() | Modeling a Simple Continuous System | Tips for Building Models | ![]() |