Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

slmetric.metric.createNewMetricClass

名前空間: slmetric.metric

カスタム モデル メトリクスの新規メトリクス クラスを作成する

説明

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 で導入