Identify and analyze algebraic loops in a model
identifies algebraic loops in the model
l = Simulink.BlockDiagram.getAlgebraicLoops(
mdl, opens the Algebraic Loops
viewer, highlights the algebraic loops in the model, and returns information about all
algebraic loops in the model as one or more
You can use the Algebraic Loops viewer to control which algebraic loops are highlighted in the model and to view information about the algebraic loops, including:
The number of algebraic loops in the model
Whether each algebraic loop is real or artificial
The loop ID for each algebraic loop
Highlight Algebraic Loops in Model
Open the model
mdl = "ex_sldemo_hydcyl";
Ensure that the algebraic loop diagnostic is configured to issue a warning or to not issue a diagnostic when the software detects an algebraic loop in the model. If you configure the model to issue an error, the error stops compilation of the model.
To check the diagnostic behavior configured in the model:
Open the Configuration Parameters dialog box. On the Modeling tab, under Setup, click Model Settings.
Select the Diagnostics pane.
Check that the Algebraic loop parameter value is
Alternatively, use the
set_param function to specify the parameter value.
The software can detect and highlight algebraic loops in the model only after the model is compiled.
set_param function to issue a command that compiles the model.
Simulink.BlockDiagram.getAlgebraicLoops function to detect and highlight algebraic loops in the model. The Algebraic Loops viewer opens and shows that the model contains one algebraic loop.
algLoops = Simulink.BlockDiagram.getAlgebraicLoops(mdl);
The algebraic loop is highlighted in the block diagram.
Simulink.BlockDiagram.getAlgebraicLoops function returns information about the algebraic loop as an
algLoops = AlgebraicLoop with properties: Model: [1x1 Simulink.BlockDiagram] Id: [0 1] VariableBlockHandles: [2x1 double] BlockHandles: [9x1 double] IsArtificial: 0
mdl — Model to analyze for algebraic loops
string | character vector | model handle
Model to analyze for algebraic loops, specified as:
A string or a character vector that defines the name of the model
A model handle
To get the handle for the current model, you can use the function
The model that you specify must be compiled.
l — Information about algebraic loops in model
AlgebraicLoop object | array of
Information about algebraic loops in model, returned as an
AlgebraicLoop object or an array of
AlgebraicLoop object has these properties:
Simulink.BlockDiagramobject that represents the model
Id— Numeric array that uniquely identifies the algebraic loop in the model
VariableBlockHandles— Array of block handles for blocks that are associated with algebraic variables in the loop
BlockHandles— Array of block handles for all blocks in the algebraic loop
IsArtificial— Logical value that indicates whether the algebraic loop is artificial
h — Handle to figure window for Algebraic Loops viewer
Handle to figure window for Algebraic Loops viewer, returned as a
You can use the handle for the Algebraic Loops viewer to interact with the Algebraic Loops viewer programmatically. For more information, see Figure Properties.
Introduced in R2015a