Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

**MathWorks Machine Translation**

The automated translation of this page is provided by a general purpose third party translator tool.

MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.

**Package: **slmetric.metric

**Superclasses: **

Metric data for specified model component and metric algorithm

Instances of `slmetric.metric.Result`

contain the metric data for a specified
model component and metric algorithm.

`metric_result = slmetric.metric.Result`

creates
a handle to a metric results object.

`ID`

— Numeric identifierinteger

Unique numeric identifier for the metric result object. This property is read-only.

**Data Types: **`uint64`

`ComponentID`

— Component IDcharacter vector

Unique identifier of the component object for which the metric is
calculated. Use `ComponentID`

to trace the generated result
object to the analyzed component. Set the `ComponentID`

or
`ComponentPath`

properties by using the `slmetric.metric.Metric.algorithm`

method.

This property is read/write.

**Data Types: **`char`

`ComponentPath`

— Component pathcharacter vector

Component path for which metric is calculated. 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 `slmetric.metric.Metric.algorithm`

method.

This property is read/write.

**Data Types: **`char`

`MetricID`

— Metric identifiercharacter vector

Metric identifier for Model Metrics or custom model
metrics that you create. You can get metric identifiers by calling `slmetric.metric.getAvailableMetrics`

.

This property is read/write.

**Data Types: **`char`

`Value`

— Metric valuedouble (default)

Metric scalar value, generated by the algorithm for the metric specified
by `MetricID`

and the component specified by
`ComponentID`

.

If the algorithm does not specify a metric scalar value, the default 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.

This property is read/write.

**Data Types: **`double`

`AggregatedValue`

— Aggregated metric valuedouble (default)

Metric value aggregated across the model hierarchy. The metric engine
implicitly aggregates the metric values based on the
`AggregationMode`

. Do not set this property. If the
metric scalar value is `NaN`

for
all components, the
`AggregatedValue`

is zero.

This property is read-only.

**Data Types: **`double`

`Measures`

— Metric measuresdouble array

Metric measures, optionally specified by the metric algorithm. 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 the property by using the
`slmetric.metric.Metric.algorithm`

method. This
property is read/write.

**Data Types: **`double`

`AggregatedMeasures`

— Aggregated metric measuresdouble array

Metric measures value aggregated across the model hierarchy. The metric
engine implicitly aggregates the metric measure values based on the
`AggregationMode`

. Do not set this property.

This property is read-only.

**Data Types: **`double`

`Details`

— Metric result detailsarray of

`slmetric.metric.ResultDetail`

objectsDetails about what the metric engine counts for the
`Value`

property

This property is read/write.

`Category`

— Metric data category based on thresholding criteria'Compliant' | 'NonCompliant' | 'Warning' | 'Uncategorized'

Metric data values fall into 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.

This property is read-only.

`Classifications`

— Metric data category and thresholding criteria`slmetric.config.ResultClassification`

objectAccess the metric data category and the ranges that correspond to each category. This property is empty if no threshold values are set.

`UserData`

— User datacharacter vector

User data optionally provided by the metric algorithm.

This property is read/write.

**Data Types: **`char`

Collect and access model metric data for the
model `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.AnalyzeModelReferences = 1; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');

Collect model metric data

execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');

Get the model metric data that returns an array of `slmetric.metric.ResultCollection`

objects, `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

Here are the results:

MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic Value: 3 AggregatedValue: 4 Measures: 0 3 AggregatedMeasures: 3 3 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic/More Info Value: 0 AggregatedValue: 0 Measures: 0 0 AggregatedMeasures: 0 0 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_counter Value: 4 AggregatedValue: 4 Measures: 3 1 AggregatedMeasures: 3 1

For the `ComponentPath: sldemo_mdlref_basic`

, the value
is `3`

because there are `3`

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
`AggregratedMeasures`

array contains the maximum number
of inputs and outputs for a component or subcomponent.

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.

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: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- 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)