Documentation

slmetric.metric.ResultCollection class

Package: slmetric.metric
Superclasses:

Metric data for specified model metric

Description

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

Construction

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

Properties

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.

IntegerStatus
1

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.

0

Result collected.

-1

No result. Error executing metric.

-2

No result available from previous run.

-3

No result. Compilation error.

-4

Empty result. Missing prerequisite.

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 slmetric.Engine.execute method for one or more metrics. This property is read-only.

Examples

expand 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.AnalyzeModelReferences = 1;
metric_engine.AnalyzeLibraries = 1;

setAnalysisRoot(metric_engine, 'Root',  'sldemo_mdlref_basic');

Collect model metric data.

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

Get the model metric data that returns an array of slmetric.metric.ResultCollection objects, res_col.

res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');

Display the results for the mathworks.metrics.SimulinkBlockCount 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)]);
        end
    else
        disp(['No results for:', result(n).MetricID]);
    end
    disp(' ');
end

Introduced in R2016a

Was this topic helpful?