slmetric.metric.Result class

Package: slmetric.metric
Superclasses:

Metric data for specified model component and metric algorithm

Description

Instances of slmetric.metric.Result contain the metric data for a specified model component and metric algorithm.

Construction

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

Properties

expand all

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

Data Types: uint64

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 algorithm method.

This property is read/write.

Data Types: char

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 algorithm method.

This property is read/write.

Data Types: char

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

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

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

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

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 about what the metric engine counts for the Value property

This property is read/write.

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.

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

User data optionally provided by the metric algorithm.

This property is read/write.

Data Types: char

Examples

collapse all

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.ModelReferencesSimulationMode = 'AllModes';
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.

Introduced in R2016a