Main Content

getMetricDistribution

Class: slmetric.Engine
Package: slmetric

Get metric distribution

Description

example

getMetricDistribution(metric_engine,MetricID) generates distribution for a specific metric, MetricID, for the metric data in the slmetric.Engine object, metric_engine. The distribution is on the metric data from the Value property of a slmetric.metric.Result object.

Input Arguments

expand all

When you call execute, metric_engine collects metric data for all available metrics or for the specified MetricID. Calling getMetrics accesses the collected metric data in metric_engine.

Metric identifier for a model metric, specified as a character vector.

Example: 'mathworks.metrics.DescriptiveBlockNames'

Output Arguments

expand all

Distribution of the metric data contains the following properties:

  • MetricID is a char array that returns the metric ID specified in the getMetricDistribution function call.

  • BinCounts is an uint64 array of the number of components corresponding to a bin.

  • BinEdges is a double array of equally spaced edges of each bin.

Examples

expand all

To generate the distribution for a specific metric, create a slmetric.Engine object, set the analysis root for the sldemo_fuelsys model, and create a histogram of the data. The histogram shows the number of components corresponding to a number of blocks.

% Create an slmetric.Engine object
metric_engine = slmetric.Engine();

% Specify model for metric analysis
setAnalysisRoot(metric_engine, 'Root', 'sldemo_fuelsys');

% Collect model metrics and get distribution
metricID = 'mathworks.metrics.SimulinkBlockCount';
execute(metric_engine, metricID);
dist = getMetricDistribution(metric_engine, metricID);

% View the distribution using a histogram.
histogram('BinEdges',dist.BinEdges,'BinCounts',dist.BinCounts);

Version History

Introduced in R2017a