Main Content

slmetric.metric.createNewMetricClass

Namespace: slmetric.metric

(To be removed) Create new metric class for a custom model metric

The Metrics Dashboard user interface, metricdashboard function, slmetric package API, and corresponding customizations will be removed in a future release. For more information, see Migrating from Metrics Dashboard to Model Maintainability Dashboard.

Description

example

slmetric.metric.createNewMetricClass(class_name) creates a slmetric.metric.Metric class in the current working folder. The new metric class is used to define a custom model metric and supports the following Advisor.component.Types:

  • Model

  • SubSystem

  • ModelBlock

  • Chart

  • MATLABFunction

Examples

collapse all

This example shows how to create a new metric class my_metric.

Call the function and provide a name for the new metric class:

slmetric.metric.createNewMetricClass('my_metric')

The function creates a my_metric.m file in the current working folder.

The file contains the class definition for my_metric, which includes the constructor and an empty metric algorithm method.

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

Write your custom metric algorithm in algorithm.

When your custom metric class is working and tested, register your metric using slmetric.metric.registerMetric.

Input Arguments

collapse all

Name of the new metric class you are creating for a custom metric.

Data Types: char

Version History

Introduced in R2016a

collapse all

R2022a: Warns

The Metrics Dashboard user interface, metricdashboard function, slmetric package API, and corresponding customizations will be removed in a future release. For more information, see Migrating from Metrics Dashboard to Model Maintainability Dashboard.