Simulink Decision Count
Metric ID
slcomp.SimulinkDecisions
Description
Use this metric to count the number of Simulink® decisions in the Simulink blocks in each layer of a unit or component.
Supported Artifacts
You can collect this metric for:
To control what the dashboard classifies as a unit or component, see Categorize Models in Hierarchy as Components or Units.
Decision Counts for Common Block Types
The following table shows how the metric calculates the decision count for common Simulink blocks.
Block or Entity | Decision Count | Description |
---|---|---|
Abs | 1 | For the decision count, the Abs block can be treated as an
if (input < 0) % one decision output = -1*input; else % default path % zero decisions output = input; end An
|
Combinatorial Logic | Number of rows in the Truth table parameter minus 1 | The decision count depends on the number of rows in the truth table. If a truth table contains five rows, the decision count is 4. One row in the truth table contains the default output and the other four rows contain potential outputs that depend on a decision being made. Note The metric expects that you specify the truth table directly inside the Combinatorial Logic block and that you specify the Truth table parameter by using a matrix that defines all possible block outputs. If the metric is unable to parse the matrix, the metric returns a decision count of 1. |
Dead Zone | 2 | The output of the Dead Zone block
depends on the block input ( For the decision count, the Dead Zone block can be treated as an
if ((U >= LL) & (U <= UL)) % one decision output = 0; elseif (U > UL) % one decision output = U - UL; else % default path % zero decisions output = U - LL; end An
|
Delay | Either 0, 1, or 2 | The decision count depends on the Show enable port parameter and the External reset parameter.
|
Discrete-Time Integrator | Either 0, 1, 2, or 3 | The decision count depends on the External reset parameter and the Limit output parameter.
|
Discrete Filter | Either 0 or 1 | The decision count depends on the External reset parameter.
|
Discrete FIR Filter | Either 0, 1, or 2 | The decision count depends on the Show enable port parameter and the External reset parameter.
|
Enabled and Triggered Model or Subsystem | 1 | For the decision count, a model or subsystem that is
enabled and triggered can be treated as an
An |
Enabled Model or Subsystem | 1 | For the decision count, a model or subsystem that is
enabled can be treated as an
An |
For Iterator Subsystem | 1 | For the decision count, the For Iterator
Subsystem block can be treated as an
An |
If | Number of if and elseif
expressions | Each The decision count is the
number of For
example, the following code contains one
if (u > 0) % one decision y = 1; elseif (u < 0) % one decision y = 2; else % default path, zero decisions y = 0; end |
Index Vector | 1 | The Index Vector block is associated with a decision count of 1. The Index Vector block is a special configuration of the Multiport Switch block in which you specify one data input and the control input is zero-based. For example, if the input vector is
|
MinMax | Either 1 or the number of input ports minus 1 | The decision count depends on the number of input ports:
|
Multiport Switch | Number of data ports minus 1 | The decision count for the Multiport Switch block depends on the number of data ports that are inputs to the block. The number of data ports represents the number of possible outcomes. The decision count is the number of data ports minus 1 because one of the possible outcomes is the default path. For the default path, no decision was made. For example, if the number of data inputs is 3, then the decision count is 2. If there is only one data port, the Multiport Switch block acts as an Index Vector block and has a decision count of 1. |
Rate Limiter | 2 | The output of the Rate Limiter block is
determined by comparing rate to the
Rising slew rate
( For the decision count, the
Rate Limiter block can be treated as an
An
|
Relay | 2 | The output of the Relay block is determined by the Switch off point and the Switch on point parameters. For the decision count, the
Relay block can be treated as an
An
|
Saturation | 2 | The output of the Saturation block is determined by comparing the input to the Upper limit and Lower limit parameters. For the decision count, the
Saturation block can be treated as an
An
|
Send | Either 0 or 1 | The decision count depends on the Show enable port parameter.
|
Sign | 2 | The output of the Sign block is determined by the input. For the decision count,
the Sign block can be treated as an
An
|
Switch | 1 | The Switch block is associated with a decision count of 1:
For example, the following code shows a decision count of 1: switch (u2 > 0) case 1 % one decision y = u1; otherwise % default path, zero decisions y = u3; end |
Switch Case | Number of outports minus 1 | The The decision count is the number of outports minus 1. For example, the following code represents a Switch Case block with 3 outputs and has a decision count of 2: switch u1 case 1 % one decision y = port1; case 2 % one decision y = port2; otherwise % default path, zero decisions y = port3; end |
Triggered Model or Subsystem | 1 | For the decision count, a model or subsystem that is
triggered can be treated as an
An |
Trigonometric Function | 0 or 3 | The decision count depends on the Function parameter and the Remove protection against out-of-range input parameter.
|
While Iterator Subsystem | 1 | For the decision count, the While Iterator
Subsystem block can be treated as an
An |
Computation Details
The metric is a heuristic that estimates the number of Simulink decisions. The calculated decision count is not exact.
The metric:
Includes active and inactive variants in the decision count.
Does not include commented blocks in the decision count.
Does not compile the model. The metric only considers static information.
Does not resolve parameters. For example, if you specify a block parameter using a variable, the metric does not resolve the parameter to the variable value because that would require the metric to compile the model.
The metric aligns with the decision coverage returned by Simulink Coverage™. For information, see Model Objects That Receive Coverage (Simulink Coverage).
Collection
To collect data for this metric, use getMetrics
with the metric identifier
slcomp.SimulinkDecisions
.
Results
For this metric, instances of metric.Result
return
Value
as the number of Simulink decisions in the Simulink blocks in each layer of a unit or component.
Examples
To see the number of Simulink decisions associated with different block types, see Decision Counts for Common Block Types.
See Also
metric.Engine
| execute
| getAvailableMetricIds
| getMetrics
Related Topics
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)