Main Content

coder.report.generateCodeMetrics

Generate static code metrics report

Description

example

coder.report.generateCodeMetrics(model) generates a static code metrics report for the code generated from model without generating a full code generation report. The default file name of the static code metrics report is metrics.html.

You can also generate a static code metrics report in a code generation report by using the function coder.report.generate or by selecting Generate Static Code Metrics for Model in the Configuration Parameters dialog box.

example

coder.report.generateCodeMetrics(subsystem) generates the static code metrics report for the subsystem. The build folder for the subsystem must be present in the current working folder.

example

coder.report.generateCodeMetrics(___,Name,Value) specifies options by using one or more Name,Value pair arguments.

Examples

collapse all

Generate code for a model, and then generate the static code metrics.

Open the model rtwdemo_counter.

open rtwdemo_counter

Turn off code generation report generation.

set_param('rtwdemo_counter','GenerateReport','off');

Build the model.

slbuild('rtwdemo_counter');

Generate a static code metrics report for the model.

coder.report.generateCodeMetrics('rtwdemo_counter');

Open the static code metrics report.

web('metrics.html');

Generate code and static code metrics for a subsystem.

Open the model rtwdemo_counter.

open rtwdemo_counter

Turn off code generation report generation.

set_param('rtwdemo_counter','GenerateReport','off');

Build the subsystem.

slbuild('rtwdemo_counter/Amplifier');

Generate a static code metrics report for the subsystem.

coder.report.generateCodeMetrics('rtwdemo_counter/Amplifier');

Open the static code metrics report.

web('metrics.html');

Generate code metrics in a report that uses a custom file name.

Open the model rtwdemo_counter.

open rtwdemo_counter

Turn off code generation report generation.

set_param('rtwdemo_counter','GenerateReport','off');

Build the model.

slbuild('rtwdemo_counter');

Generate a static code metrics report for the model. Name the generated code metrics report code_metrics.html.

coder.report.generateCodeMetrics('rtwdemo_counter','FileName','code_metrics.html');

Open the static code metrics report.

web('code_metrics.html');

Input Arguments

collapse all

Model name, specified as a character vector or string scalar.

Example: 'rtwdemo_counter'

Data Types: char

Subsystem name, specified as a character vector or sting scalar.

Example: 'rtwdemo_counter/Amplifier'

Data Types: char

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'FileName','X:\code_metrics.html' creates a static code metrics report named code_metrics.html.

Build folder that contains the generated code, specified as a character vector or string scalar.

Example: 'BuildDir','X:\rtwdemo_comments_ert_rtw'

Name of the generated static code metrics HTML file, specified as a character vector or string scalar.

Example: 'FileName','X:\code_metrics.html'

Version History

Introduced in R2020b