This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

slmetric.config.Threshold class

Package: slmetric.config

Object for holding metric result thresholds

Description

Object for holding metric data thresholds

Construction

For an slmetric.config.ThresholdConfiguration object, use the addThreshold method to create an slmetric.config.Threshold object. You can add multiple threshold objects to the same threshold configuration object. Each threshold object is for specifying threshold values for a specific model metric. You can specify metric values for the Value or AggregatedValue properties of an slmetric.metric.Result object.

Properties

expand all

Metric identifier for model metric or custom model metric that you create. This property is read-only.

Example: 'mathworks.metrics.SimulinkBlockCount'

Data Types: char

slmetric.metric.Result property to which you apply thresholds. You can apply thresholds to the Value and AggregatedValue properties. This property is read-only.

Data Types: char

Methods

addClassification Add metric data classification to slmetric.config.Threshold object
getClassificationsObtain metric data classifications
removeClassification Remove metric threshold classification
validate Validate metric range thresholds

Examples

collapse all

Use the slmetric.config packaged classes to add threshold information to the Metrics Dashboard. 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);

Add an slmetric.config.Threshold object 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');

An slmetric.config.Threshold object contains a default slmetric.config.Classification object that corresponds to the Compliant category. Use the slmetric.metric.MetricRange class to specify metric values for the Compliant metric range.

C = getClassifications(T); % default classification is Compliant
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.

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.

Introduced in R2018b