slmetric.metric.ResultCollection class

Package: slmetric.metric

Metric data for specified model metric


Instances of slmetric.metric.ResultCollection contain the metric data for a specific model metric.


metricRC = slmetric.metric.ResultCollection creates a handle to a metric result collection object.


expand all

Metric identifier for a MathWorks metric or a custom metric. You can get metric identifiers by calling slmetric.metric.getAvailableMetrics.

Status code of metric execution. This property is read-only.


No result. Metric algorithm is not applicable to the analyzed system. Components analyzed by the metric not found, or metric with compile requirement cannot be executed on library model.


Result collected.


No result. Error executing metric.


No result available from previous run.


No result. Compilation error.


Empty result. Missing prerequisite.

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 has no threshold values.

If at least one component is NonCompliant, this property returns NonCompliant. If at least one component is Warning and no components are NonCompliant, this property returns Warning. If all components are Compliant, this category returns Compliant.

This property is read-only.

If true, the metric data is out-of-date because the model or source files have changed. This property is read-only.

Metric data collected when you call the execute method for one or more metrics. This property is read-only.


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)]);
        disp(['No results for:', result(n).MetricID]);
    disp(' ');

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