主要内容

本页采用了机器翻译。点击此处可查看英文原文。

slmetric.metric.createNewMetricClass

命名空间: slmetric.metric

(待删除)为自定义模型度量创建新的度量类

以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅从度量盘迁移到模型可维护性仪表盘

说明

slmetric.metric.createNewMetricClass(class_name) 在当前工作文件夹中创建一个 slmetric.metric.Metric 类。新的度量类用于定义自定义模型度量,并支持以下Advisor.component.Types

  • Model

  • SubSystem

  • ModelBlock

  • Chart

  • MATLABFunction

示例

示例

全部折叠

本示例展示了如何创建一个新的度量类 my_metric

调用该函数并为新的度量类提供一个名称:

slmetric.metric.createNewMetricClass('my_metric')

该函数会在当前工作文件夹中创建一个 my_metric.m 文件。

该文件包含 my_metric 类的定义,其中包括构造函数和一个空的度量 algorithm 方法。

classdef my_metric < slmetric.metric.Metric
    %my_metric Summary of this metric class goes here
    %   Detailed explanation goes here
    properties
    end
    
    methods
        function this = my_metric()
            this.ID = 'my_metric';
            this.ComponentScope = [Advisor.component.Types.Model, ...
                Advisor.component.Types.SubSystem];
            this.AggregationMode = slmetric.AggregationMode.Sum;
            this.CompileContext = 'None';
            this.Version = 1;
            this.SupportsResultDetails = false;
            
            %Textual information on the metric algorithm
            this.Name = '';
            this.Description = '';
            this.ValueName = '';
            this.AggregatedValueName = '';
            this.MeasuresNames = {};
            this.AggregatedMeasuresNames = {};
        end
        
        function res = algorithm(this, component)
            res = slmetric.metric.Result();	
            res.ComponentID = component.ID;
            res.MetricID = this.ID;
            res.Value = 0;
        end
    end
end

algorithm 中编写您的自定义度量算法。

当您的自定义度量类运行正常并通过测试后,使用 slmetric.metric.registerMetric 注册您的度量。

输入参数

全部折叠

为自定义度量创建的新度量类的名称。

数据类型: char

版本历史记录

在 R2016a 中推出

全部折叠