Main Content

slmetric.dashboard.Layout class

Package: slmetric.dashboard

Create object for holding Metrics Dashboard customizations


Object that holds an array of widget objects. The size, types, and locations of widgets in an slmetric.dashboard.Layout object determine the Metrics Dashboard appearance. These are the widget objects:

  • slmetric.dashboard.Group

  • slmetric.dashboard.Container

  • slmetric.dashboard.Widget

  • slmetric.dashboard.CustomWidget


For an slmetric.dashboard.Configuration object, use the getDashboardLayout method to create an slmetric.dashboard.Layout object. You can add or remove widgets from this object. You can specify the size and location of these widgets in the Metrics Dashboard. Once you complete your specification, apply the method to save your configuration. Use the slmetric.dashboard.setActiveConfiguration function to set the active configuration.

The Metrics Dashboard layout is divided into 12 columns of equal size. Use the widget object methods to specify widget size.


addWidget Add widget to slmetric.dashboard.Layout object
getWidgetsObtain a list of widgets in an slmetric.dashboard.Layout object
removeWidget Remove widget from slmetric.dashboard.Layout object


collapse all

You can use the Metrics Dashboard and metric APIs to obtain compliance and issues metric data on your Model Advisor configuration. To set up your Model Advisor configuration, see Use Model Advisor Configuration Editor to Customize Model Advisor. You can also use an existing check group such as the MISRA checks. After you have set up your Model Advisor configuration, follow these steps to specify the check groups for which you want to obtain compliance and issues metric data:

Open the model vdp by entering:


Open the default configuration:

config =

Specify a metric family ID that you associate with those check groups:

famParamID = 'ModelAdvisorStandard';

Create a cell array consisting of the Check Group IDs that correspond to the check groups. Obtain a Check Group ID by opening up the Model Advisor Configuration Editor and selecting the folder that contains the group of checks. The folder contains a Check Group ID parameter.

values = {'maab', 'hisl_do178', '_SYSTEM_By Task_misra_c'};

The previous cell array specifies MAB, High-Integrity, and MISRA check groups. The values maab and hisl_do178 correspond to a subset of MAB and High-Integrity System checks. To include all checks, specify the value for the Check Group ID parameter from the Model Advisor Configuration Editor.

To set up the configuration, pass the values cell array into the setMetricFamilyParameterValues method.

setMetricFamilyParameterValues(config, famParamID, values);

In the Modeling Guideline Compliance section, replace the High Integrity dial widget and High Integrity bar widget with widgets that use results from the MISRA check group instead. To begin, open the default configuration for the Metrics Dashboard layout.

conf =;

Obtain the slmetric.dashboard.Layout object from the slmetric.dashboard.Configuration object conf.

layout = getDashboardLayout(conf);

Obtain the widget objects that are in the layout object.

layoutWidget = getWidgets(layout);

Obtain the compliance group from the layout. This group contains two containers. The first container contains the High Integrity dial widget, MAB dial widget, and Model Advisor Check Issues bar chart widget. Remove the High Integrity dial widget.

complianceGroup = layoutWidget(3);
complianceContainers = getWidgets(complianceGroup);
complianceContainerWidgets = getWidgets(complianceContainers(1));
({'mathworks.metrics.ModelAdvisorCompliance._SYSTEM_By Task_misra_c'}));
complianceContainerWidgets(1).Labels = {'MISRA'};

Add a custom widget for visualizing MISRA check issues metrics to the complianceContainers slmetric.dashboard.Container object.

misraWidget = complianceContainers(1).addWidget('Custom', 1); 
misraWidget.Title = ('MISRA'); 
misraWidget.VisualizationType = 'RadialGauge'; 
misraWidget.setMetricIDs('mathworks.metrics.ModelAdvisorCheckCompliance._SYSTEM_By Task_misra_c'); 

Save the configuration objects. These commands serialize the API information to XML files.


Set the active configurations.

slmetric.config.setActiveConfiguration(fullfile(pwd, 'MetricConfig.xml'));
slmetric.dashboard.setActiveConfiguration(fullfile(pwd, 'DashboardConfig.xml'));

Open the Metrics Dashboard for the model vdp.

metricsdashboard vdp

Click the All Metrics button to run all metrics.

Version History

Introduced in R2018b