Main Content

addClassification

Add metric data classification to slmetric.config.Threshold object

Description

example

TC = addClassification(threshold,category) adds a classification category to an slmetric.config.Threshold object.

After creating the object, use the slmetric.config.MetricRange object functions to specify ranges for Compliant, NonCompliant, and Warning. By default, a classification object has a Compliant range of -inf to inf. The Metrics Dashboard indicates the range that your metric data falls under.

Examples

collapse all

Add threshold information to the Metrics Dashboard by using slmetric.config.Threshold and slmetric.config.Configuration objects. You can add thresholds that define metric data ranges for these three categories:

  • Compliant — Metric data that is an acceptable range

  • Warning — Metric data that requires review

  • Noncompliant — Metric data that requires you to modify your model

Create an slmetric.config.Configuration object.

CONF = slmetric.config.Configuration.new('name', 'Config');

Get the default slmetric.config.ThresholdConfiguration object in CONF.

TC = getThresholdConfigurations(CONF);

Create an slmetric.config.Threshold object and add it to the slmetric.config.ThresholdConfiguration object. This threshold is for the mathworks.metrics.SimulinkBlockCount metric and the Value property of the slmetric.metric.Results object.

T = addThreshold(TC, 'mathworks.metrics.SimulinkBlockCount', 'Value');

By default, the slmetric.config.Threshold object contains a slmetric.config.Classification object that defines metric ranges in the compliant category. Get the classification object by using the function getClassifications on the threshold object T.

C = getClassifications(T);

The Range property of the classification object is a slmetric.metric.MetricRange object. Specify metric values for the compliant category by using the slmetric.metric.MetricRange functions on the range of the classification object.

C.Range.Start = 5;
C.Range.IncludeStart = 0;
C.Range.End = 100;
C.Range.IncludeEnd = 0;

These values specify that a compliant range is a block count from 5 to 100. This range does not include the values 5 and 100.

Specify values for the warning metric range.

C = addClassification(T,'Warning');
C.Range.Start = -inf;
C.Range.IncludeStart = 0;
C.Range.End = 5;
C.Range.IncludeEnd = 1;

These values specify that a warning is a block count between -inf and 5. This range does not include -inf. It does include 5.

Specify values for the noncompliant metric range.

C = addClassification(T,'NonCompliant');
C.Range.Start = 100;
C.Range.IncludeStart = 1;
C.Range.End = inf;
C.Range.IncludeEnd = 0;

These values specify that a block count greater than 100 is noncompliant. This range includes 100. It does not include inf.

Use the validate method to validate the metric ranges corresponding to the thresholds in the slmetric.config.ThresholdConfiguration object.

validate(T)

If the ranges are not valid, you get an error message. In this example, the ranges are valid, so the function returns nothing.

Save the changes to the configuration file. Use the slmetric.config.setActiveConfiguration function to activate this configuration for the metric engine to use.

configName = 'Config.xml';
save(CONF,'FileName', configName);
slmetric.config.setActiveConfiguration(fullfile(pwd, configName));

You can now run the Metrics Dashboard with this custom configuration on a model.

Input Arguments

collapse all

Metric threshold, specified as an slmetric.config.threshold object.

Threshold category, specified as one of these three 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

Data Types: char

Output Arguments

collapse all

Classification category, returned as a slmetric.config.Classification object.

Introduced in R2018b