coder.report.generateCodeMetrics - Generate static code metrics report - MATLAB (original) (raw)
Generate static code metrics report
Since R2020b
Syntax
Description
coder.report.generateCodeMetrics([model](#mw%5Fe69b8637-fc55-4c32-acd9-66f0c36a5632))
generates a static code metrics report for the code generated frommodel
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.
coder.report.generateCodeMetrics([subsystem](#mw%5F4998f2e9-eecd-4527-9bec-c9528f26ec51))
generates the static code metrics report for the subsystem
. The build folder for the subsystem must be present in the current working folder.
coder.report.generateCodeMetrics(___,[Name,Value](#namevaluepairarguments))
specifies options by using one or more Name,Value
pair arguments.
Examples
Generate code for a model, and then generate the static code metrics.
Open the model CounterModel
.
openExample('CounterModel.slx')
Turn off code generation report generation.
set_param('CounterModel','GenerateReport','off');
Build the model.
Generate a static code metrics report for the model.
coder.report.generateCodeMetrics('CounterModel');
Open the static code metrics report.
Generate code and static code metrics for a subsystem.
Open the model CounterModel
.
openExample('CounterModel.slx')
Turn off code generation report generation.
set_param('CounterModel','GenerateReport','off');
Build the subsystem.
slbuild('CounterModel/Amplifier');
Generate a static code metrics report for the subsystem.
coder.report.generateCodeMetrics('CounterModel/Amplifier');
Open the static code metrics report.
Generate code metrics in a report that uses a custom file name.
Open the model CounterModel
.
openExample('CounterModel.slx')
Turn off code generation report generation.
set_param('CounterModel','GenerateReport','off');
Build the model.
Generate a static code metrics report for the model. Name the generated code metrics report code_metrics.html
.
coder.report.generateCodeMetrics('CounterModel','FileName','code_metrics.html');
Open the static code metrics report.
web('code_metrics.html');
Input Arguments
Model name, specified as a character vector or string scalar.
Example: 'CounterModel'
Data Types: char
Subsystem name, specified as a character vector or sting scalar.
Example: 'CounterModel/Amplifier'
Data Types: char
Name-Value Arguments
Specify optional pairs of arguments asName1=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:\CustomCodeComments_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