slmetric.metric.Result
(To be removed) Metric data for specified model component and metric algorithm
The Metrics Dashboard user interface, metricdashboard
function, slmetric
package API, and corresponding customizations will be removed in a future release. For more information, see Migrating from Metrics Dashboard to Model Maintainability Dashboard.
Description
An slmetric.metric.Result
object contains the metric data
for a specified model component and metric algorithm.
Creation
Description
creates a handle to a metric results object.metric_result
= slmetric.metric.Result
Alternatively, if you collect results in an
slmetric.metric.ResultCollection
object, the
Results
property of the collection object returns the
collected slmetric.metric.Result
objects in an array.
Properties
ID
— Numeric identifier
integer
This property is read-only.
Unique numeric identifier for the metric result object, returned as an integer.
Data Types: uint64
ComponentID
— Component identifier
character vector
Unique identifier of the component object for which the metric is
calculated, specified as a character vector. Use
ComponentID
to trace the generated result object to
the analyzed component. Set the ComponentID
or
ComponentPath
properties by using the algorithm
method.
Example: 'sldemo_mdlref_basic'
Data Types: char
ComponentPath
— Component path
character vector
Component path for which metric is calculated, specified as a character
vector. Use ComponentPath
as an alternative to setting
the ComponentID
property. The metric engine converts the
ComponentPath
to a ComponentID
.
Set the ComponentID
or ComponentPath
properties by using the algorithm
method.
Example: 'vdp/More Info/Model
Info/EmptySubsystem'
Data Types: char
MetricID
— Metric identifier
character vector
Metric identifier for Model Metrics or custom model
metrics that you create, specified as a character vector. You can get metric
identifiers by calling slmetric.metric.getAvailableMetrics
.
Example: 'mathworks.metrics.SimulinkBlockCount'
Data Types: char
Value
— Metric value
double
Metric scalar value generated by the algorithm for the metric specified by
MetricID
and the component specified by
ComponentID
, specified as a double.
If the algorithm does not specify a metric scalar value, the value of
Value
is NaN
. For example, suppose
you collect metric data for a model that contains a Stateflow Chart. For the
StateflowChartObjectCount
metric, the
Value
property of the model
slmetric.metric.Result
object is
NaN
because the model itself cannot have Stateflow
objects. The AggregatedValue
property of the model
slmetric.metric.Result
object contains the total
number of Stateflow objects in the chart.
Data Types: double
AggregatedValue
— Aggregated metric value
double
This property is read-only.
Metric value aggregated across the model hierarchy, returned as a double.
The metric engine implicitly aggregates the metric values based on the
AggregationMode
. If the Value
property is NaN
for all
components, the AggregatedValue
is zero.
Data Types: double
Measures
— Metric measures
double array
Metric measures, specified by the metric algorithm, specified as a double array. Metric measures contain detailed information about the metric value. For example, for a metric that counts the number of blocks per subsystem, you can specify measures that contain the number of virtual and nonvirtual blocks. The metric value is the sum of the virtual and nonvirtual block count.
Set this property by using the
slmetric.metric.Metric.algorithm
method.
Data Types: double
AggregatedMeasures
— Aggregated metric measures
double array
This property is read-only.
Metric measures value aggregated across the model hierarchy, returned as a
double array. The metric engine implicitly aggregates the metric measure
values based on the AggregationMode
.
Data Types: double
Details
— Metric result details
array of slmetric.metric.ResultDetail
objects
Details about what the metric engine counts for the
Value
property, specified as an array of
slmetric.metric.ResultDetail
objects.
Category
— Metric data category based on thresholding criteria
'Compliant' | 'NonCompliant' | 'Warning' | 'Uncategorized'
This property is read-only.
Metric data category, returned as one of these four categories:
Compliant — Metric data that is in an acceptable range.
Warning — Metric data that requires review.
NonCompliant — Metric data that requires you to modify your model.
Uncategorized — Metric data that does not have threshold values set.
Classifications
— Metric data category and thresholding criteria
slmetric.config.ResultClassification
object
Metric data category and the ranges that correspond to each category,
specified as an slmetric.config.ResultClassification
object. This property is empty if no threshold
values are set.
UserData
— User data
character vector
User data optionally provided by the metric algorithm, specified as a character vector.
Data Types: char
Examples
Collect and Access Metric Data for One Metric
This example shows how to collect and access metric data for the model sldemo_mdlref_basic
.
Open the sldemo_mdlref_basic
model.
open_system('sldemo_mdlref_basic');
Create an slmetric.Engine
object and set the root in the model for analysis.
metric_engine = slmetric.Engine(); % Include referenced models and libraries in the analysis, % these properties are on by default metric_engine.ModelReferencesSimulationMode = 'AllModes'; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic')
Collect model metric data.
execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Return the model metric data as an array of slmetric.metric.ResultCollection
objects and assign it to res_col
.
res_col = getMetrics(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Display the results for the mathworks.metrics.ExplicitIOCount
metric.
for n=1:length(res_col) if res_col(n).Status == 0 result = res_col(n).Results; for m=1:length(result) disp(['MetricID: ',result(m).MetricID]); disp([' ComponentPath: ',result(m).ComponentPath]); disp([' Value: ', num2str(result(m).Value)]); disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]); disp([' Measures: ', num2str(result(m).Measures)]); disp([' AggregatedMeasures: ', num2str(result(m).AggregatedMeasures)]); end else disp(['No results for:', result(n).MetricID]); end disp(' '); end
For ComponentPath: sldemo_mdlref_basic
, the value is 3
because there are three outputs. The three outputs are in the second element of the Measures
array. The slmetric.metric.AggregationMode
is Max
, so the AggregatedValue
is 4
, which is the number of inputs and outputs to sldemo_mdlref_counter
. The AggregatedMeasures
array contains the maximum number of inputs and outputs for a component or subcomponent.
Version History
Introduced in R2016aR2022a: Metrics Dashboard will be removed
The Metrics Dashboard user interface, metricdashboard
function, slmetric
package API, and corresponding customizations will be removed in a future release. For more information, see Migrating from Metrics Dashboard to Model Maintainability Dashboard.
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)