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.

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');

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');

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');

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 comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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'

Introduced in R2020b