Main Content

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

example

metric_result = slmetric.metric.Result creates a handle to a metric results object.

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

expand all

This property is read-only.

Unique numeric identifier for the metric result object, returned as an integer.

Data Types: uint64

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

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

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

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

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

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

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 about what the metric engine counts for the Value property, specified as an array of slmetric.metric.ResultDetail objects.

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.

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.

User data optionally provided by the metric algorithm, specified as a character vector.

Data Types: char

Examples

collapse all

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 R2016a

collapse all

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