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 frommodelwithout generating a full code generation report. The default file name of the static code metrics report ismetrics.html.

您还可以通过使用该函数在代码生成报告中生成静态代码指标报告coder.report.generateor by selectingGenerate Static Code Metrics for Modelin the Configuration Parameters dialog box.

example

coder.report.generateCodeMetrics(subsystem)generates the static code metrics report for thesubsystem. 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 moreName,Valuepair arguments.

Examples

collapse all

生成代码的模型,一个d then generate the static code metrics.

Open the modelrtwdemo_counter.

openrtwdemo_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 modelrtwdemo_counter.

openrtwdemo_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 modelrtwdemo_counter.

openrtwdemo_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 reportcode_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 asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein quotes.

Example:'FileName','X:\code_metrics.html'creates a static code metrics report namedcode_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