Clear Filters
Clear Filters

What are algebraic loops in Simulink and how do I solve them?

700 views (last 30 days)
I am receiving the following warning message when I run my model:
ERROR: Warning: Block diagram 'algloop' contains 1 algebraic loop(s).
Found algebraic loop containing block(s):

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Apr 2023
Edited: MathWorks Support Team on 19 Apr 2023
Algebraic loops are discussed in the Simulink User's Guide, available at the following URL:
Basically, algebraic loops occur when an input port with direct feedthrough is driven by the output of the same block, either directly, or by a feedback path through other blocks which have direct feedthrough.
Algebraic loops are difficult to solve mathematically. Simulink does have algebraic loop solvers that will attempt to resolve this situation iteratively and give the correct answer, which in a lot of cases it does. For instance, take a sum block with two inputs (one additive, the other subtractive), feed the output of the sum block to one of the inputs and you've created an algebraic loop. In this case, there is a pathway through your model where all of the blocks include direct feedthrough, although this is probably unintentional.
Here is a simplified example of what is happening, which shows this a little more clearly:
y(t) = u(t) - y(t)
As you can see, the block can't just solve its output as it needs to compute it. Simulink detects instances such as these (i.e. algebraic loops) and solves them using an iterative loop. Simulink will compute the correct result in the above example, which is:
y(t) = u(t) / 2
Even when the equations are a little more complicated, the principles are the same. Simulink has built-in solvers which solve these equations, however, as you have seen, not all problems can be solved.
If an algebraic loop is detected you have two options: leave the algebraic loop intact, or eliminate it. If the speed of execution of the model is acceptable, leaving the loop is probably the better choice. If the speed of execution is slow, you must eliminate the algebraic loop.
One solution may be to use an Initial Condition block or an Algebraic Constraint block, as described in the Simulink User's Guide, to help the loop solver. However, there are still situations where this is not adequate. If this is the case, it will be necessary to try to solve the algebraic loop and change the way that your model is set up so that the loop is no longer present.
In many cases, the solution is to model the system so that the loop is no longer present. In some cases, adding a small delay (Either discrete delay block or continuous memory block) to the system at its highest level might remove the loop. However, this can, in some situations, add unnecessary dynamics which may affect the results.
If your loop involves an integrator whose output you are feeding back as either a reset trigger or external initial condition, use the StatePort option to remove the loop. You can find more information on this State port in the Simulink User's Guide under the help for the Integrator Block.
The online version of the Simulink User's Guide can be found at:
For suggestions on how to resolve a continuous algebraic loop, please refer to the following post:

More Answers (1)

Larasmoyo Nugroho
Larasmoyo Nugroho on 28 Jan 2017
adding a memory block to the feedback loop is working for me..
  1 Comment
Jorik on 24 Jul 2017
Edited: Jorik on 24 Jul 2017
I would recommend NOT to use a Memory block to break an algebraic loop if the loop uses a continuous sample time. Please see this for reference:

Sign in to comment.

MathWorks Support


Find more on General Applications in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!