Documentation

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 slmetric.metric.Metric.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 slmetric.metric.Metric.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.

This property is read/write.

Data Types: double

Metric value aggregated across the model hierarchy. The metric engine implicitly aggregates the metric values. Do not set this property.

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

User data optionally provided by the metric algorithm.

This property is read/write.

Data Types: char

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?