Simulink.BlockDiagram.getAlgebraicLoops

Show algebraic loops in a model

Description

example

Simulink.BlockDiagram.getAlgebraicLoops(model) returns a list of algebraic loops in a model as a vector of AlgebraicLoops objects.

The Algebraic Loops viewer provides a tabular list of all algebraic loops in the model. Use the Algebraic Loops viewer to control the display of algebraic loops in your model.

[loops,h] = Simulink.BlockDiagram.getAlgebraicLoops(model)

Examples

collapse all

Open the ex_sldemo_hydcyl model.

In the Diagnostics pane of Model Configuration Parameters, set Algebraic loop to none or warning. Setting this parameter to error prevents the model from compiling.

Compile the model without any errors. The model must compile before you can highlight any algebraic loops.

At the MATLAB command prompt, enter:

mdl = 'ex_sldemo_hydcyl';
load_system(mdl);
Simulink.BlockDiagram.getAlgebraicLoops(bdroot)
  AlgebraicLoop with properties:

                   Model: [1×1 Simulink.BlockDiagram]
                      Id: [0 1]
    VariableBlockHandles: [198.0001 145.0001]
            BlockHandles: [9×1 double]
            IsArtificial: 0

The resulting output shows that the model has one algebraic loop, which contains three blocks.

Running the getAlgebraicLoops function also opens the Algebraic Loop viewer. Use the Algebraic loop viewer to highlight specific algebraic loops in your model or all the loops.

The selected loops are highlighted in the corresponding model, in.

Input Arguments

collapse all

Name of the model being tested, specified as a string scalar or character vector. You can also pass the most recently opened model using bdroot.

Note

The model must be loaded into memory using either open_system or load_system.

Data Types: char | string

Output Arguments

collapse all

Every algebraic loop in the model returned as an AlgebraicLoop object that contains the following information:

  • ModelSimulink.BlockDiagram object representing the model

  • Id— Index of the algebraic loop in the model

  • VariableBlockHandles: Handles to blocks that have been assigned algebraic variables

  • BlockHandles—Handles to all the blocks contained in the algebraic loop

  • IsArtificial— Boolean value indicating whether the loop is an artificial algebraic loop.

The control UI is a MATLAB® figure window. Use the UI's handle h to control it programmatically. For more information, see Figure Properties.

Introduced before R2006a