Documentation

slmetric.metric.createNewMetricClass

Package: slmetric.metric

Create new metric class for a custom model metric

Syntax

slmetric.metric.createNewMetricClass(class_name)

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.

slmetric.metric.createNewMetricClass('my_metric')

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.Description = '';
				this.ComponentScope = [Advisor.component.Types.Model, ...
					Advisor.component.Types.SubSystem];
				this.AggregationMode = slmetric.AggregationMode.Sum;
				this.AggregateComponentDetails = true;
				this.CompileContext = 'None';
				this.Version = 1;
			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

Introduced in R2016a

Was this topic helpful?