主要内容

slmetric.config.ThresholdConfiguration 类

命名空间: slmetric.config

(即将删除)指定用于设置阈值的度量和 slmetric.metric.Result 属性

以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅Migrating from Metrics Dashboard to Model Maintainability Dashboard

描述

slmetric.config.ThresholdConfiguration 的实例包含您为某个度量指定的阈值。每个阈值设定对应一个 slmetric.config.Threshold 对象。一个 slmetric.config.ThresholdConfiguration 对象可以包含多个 slmetric.config.Threshold 对象。

构造

对于 slmetric.config.Configuration 对象,请使用 getThresholdConfigurations 方法来访问 slmetric.config.ThresholdConfiguration 对象。

方法

addThreshold(To be removed) Create slmetric.config.Threshold object
getThresholds(To be removed) Obtain properties of threshold objects
removeThreshold(即将删除)从阈值配置对象中删除阈值对象

示例

全部折叠

使用 slmetric.config 打包的类向度量仪表板添加阈值信息。您可以添加阈值来定义以下三个类别的度量数据范围:

  • Compliant - 在可接受范围内的度量数据。

  • Warning - 需要审核的度量数据。

  • Noncompliant - 需要您修改模型的度量数据。

创建一个 slmetric.config.Configuration 对象。

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

获取 CONF 中的默认 slmetric.config.ThresholdConfiguration 对象。

TC = getThresholdConfigurations(CONF);

slmetric.config.Threshold 对象添加到 slmetric.config.ThresholdConfiguration 对象。此阈值用于 slmetric.metric.Results 对象的 mathworks.metrics.SimulinkBlockCount 度量和 Value 属性。

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

slmetric.config.Threshold 对象包含与 Compliant 类别对应的默认 slmetric.config.Classification 对象。使用 slmetric.metric.MetricRange 类指定 Compliant 度量范围的度量值。

C = getClassifications(T); % default classification is Compliant
C.Range.Start = 5;
C.Range.IncludeStart = 0;
C.Range.End = 100;
C.Range.IncludeEnd = 0;

这些值指定合规范围是从 5100 的模块计数。此范围不包括值 5100

指定 Warning 度量范围的值。

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

这些值指定警告是介于 -inf5 之间的模块计数。此范围不包括 -inf。但它确实包括 5

指定 NonCompliant 度量范围的值。

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

这些值指定大于 100 的模块计数不符合要求。此范围包括 100。但它不包括 inf

使用 slmetric.config.validate 函数验证与 slmetric.config.ThresholdConfiguration 对象中的阈值对应的度量范围。

validate(T)

如果范围无效,您会收到一条错误消息。在此示例中,该范围有效。

保存对配置文件的更改。使用 slmetric.config.setActiveConfiguration 函数激活此配置以便度量引擎使用。

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

现在,您可以使用此自定义配置对模型运行度量仪表板。

版本历史记录

在 R2018b 中推出

全部折叠