slreportgen.report.MATLABFunction Class
Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter
MATLAB Function block or Stateflow MATLAB function reporter
Description
Use an object of the slreportgen.report.MATLABFunction
class to report
on a Simulink®
MATLAB Function block or Stateflow®
MATLAB® function.
By default, a MATLABFunction
reporter adds this information to a
report:
Simulink MATLAB Function block or Stateflow MATLAB function properties
A summary of the function input and output arguments
The MATLAB code used by the function to compute its outputs from its inputs
Use the reporter properties to include other information, such as detailed argument properties, function symbol properties, and supporting functions.
Note
To use a MATLABFunction
reporter in a report, you must create the
report using the slreportgen.report.Report
class.
The slreportgen.report.MATLABFunction
class is a handle
class.
Creation
Description
creates an empty reporter
= slreportgen.report.MATLABFunctionMATLABFunction
reporter based on the default
template. Use the Object
property to specify the Simulink
MATLAB Function block or Stateflow
MATLAB function to report.
sets the reporter
= slreportgen.report.MATLABFunction(mlfcnObj)Object
property to the MATLAB Function block or
Stateflow
MATLAB function specified by mlfcnObj
.
sets reporter
= MATLABFunction(Name=Value)MATLABFunction
reporter properties using name-value pairs. You can specify multiple
name-value pair arguments in any order.
Properties
Object
— MATLAB function block or Stateflow
MATLAB function
[]
(default) | character vector | string scalar | function handle
MATLAB function block or Stateflow MATLAB function to report, specified as one of these values:
Character vector or string scalar that contains the path to a MATLAB Function block
Handle to a MATLAB Function block or Stateflow MATLAB function
Note
If you use a finder to find a MATLAB Function block or
Stateflow
MATLAB function and add the result directly to a report, an
slreportgen.report.MATLABFunction
reporter is used
instead of a Simulink object property reporter.
IncludeObjectProperties
— Whether to include object properties
true (default) | false
Whether to include object properties, specified as a
true
or false
. If the value is
true
, the report includes a table of the properties
of the Simulink or Stateflow object that corresponds to the MATLAB Function
block or Stateflow
MATLAB function being reported.
ObjectPropertiesReporter
— Object properties reporter
mlreportgen.report.BaseTable
object
Object properties reporter, specified as an mlreportgen.report.BaseTable
object. The
MATLABFunction
reporter uses the specified reporter to
create a table of the properties of the Simulink or Stateflow object that corresponds to the MATLAB Function
block or Stateflow
MATLAB function being reported.
For a Simulink MATLAB Function block, these properties are reported:
Update Method
Sample Time
Support variable-size arrays
Saturate on integer overflow
Treat these inherited Simulink signal types as fi objects
MATLAB Function block fimath
Input fi math
Description
For a Stateflow MATLAB function, these properties are reported:
Saturate on integer overflow
MATLAB function fimath
Input fi math
Description
To customize the appearance of the function property table and its title,
customize the default BaseTable
reporter or replace it with a
custom version of the BaseTable
reporter. To customize the
title of the function property table, specify the contents in the
Title
property of the default or replacement
reporter. The content you specify is placed at the front of the default
title.
IncludeArgumentSummary
— Include summary of arguments
true
(default) | false
Whether to include an argument summary table, specified as
true
or false
. If the value is
true
, the report includes a summary table of the
properties of the arguments of the reported function.
ArgumentSummaryProperties
— Argument properties to include
{'Name' 'Scope' 'Port' 'Compiled Type' 'Compiled
Size'}
(default) | cell array of character vectors | string array
Argument properties to include in the argument summary table, specified as
a cell array of character vectors or a string array. If the model is not
already compiled, the MATLABFunction
reporter compiles the
model to obtain Compiled Type
, Compiled
Size
, and Variable Size
data. When the
report is closed, the model is uncompiled.
Specify any combination of these properties:
Name
Scope
Port
Compiled Type (Data Type)
Compiled Size (Size)
Complexity
Description
Maximum (Max Value)
Minimum (Min Value)
Tunable
Variable Size
ArgumentSummaryReporter
— Argument summary reporter
mlreportgen.report.BaseTable
object
Argument summary reporter, specified as an mlreportgen.report.BaseTable
object. The
MATLABFunction
reporter uses this reporter to create a
table of the arguments of the MATLAB function. The table includes a summary of the arguments and
the argument properties specified by the ArgumentSummaryProperties
property.
To customize the appearance of the argument summary table and the content
of its title, customize the default BaseTable
object or
replace it with a custom version of the BaseTable
object.
IncludeArgumentProperties
— Whether to Include details for each argument
false (default) | true
Whether to include a property table with detailed information for each
argument, specified as true
or false
.
If the value is true
, the report includes a property
table for each argument of the MATLAB function. If the model is not already compiled, the
MATLABFunction
reporter compiles the model. When the
report is closed, the model is uncompiled.
ArgumentPropertiesReporter
— Argument properties reporter
mlreportgen.report.BaseTable
object
Argument properties reporter, specified as an mlreportgen.report.BaseTable
object. The
MATLABFunction
reporter uses the specified reporter to
create a table of the properties of each argument of the MATLAB function. The default value of this property is a
BaseTable
object with the
TableStyleName
property set to the
MATLABFunctionArgumentPropertiesTable
style, which is
defined in the default template for a MATLABFunction
reporter.
To customize the appearance of the argument property table, customize the
default BaseTable
reporter or replace it with a custom
BaseTable
reporter.
IncludeFunctionScript
— Whether to Include function script
true (default) | false
Whether to include the script of the MATLAB function, specified as a true
or
false
. If the value is true
, the
report includes the code that computes the output of the MATLAB function from its inputs.
FunctionScript
— Function code formatter
mlreportgen.dom.Paragraph
object
Function code formatter, specified as an mlreportgen.dom.Paragraph
object. The Paragraph
object controls the formatting, such as
the font family, font size, and alignment, of the code in the MATLAB function. It does not control whether the reporter highlights
code syntax. The default Style
property is set to
mlreportgen.dom.WhiteSpace
.
To control the highlighting, use the HighlightScriptSyntax
property.
To customize the code appearance, modify the properties of the default
Paragraph
reporter or replace the reporter with a custom
reporter. If you add content to the default or replacement
Paragraph
reporter, the content is placed before the
MATLAB Function script in the generated report.
FunctionScriptTitle
— Function script section title
mlreportgen.dom.Paragraph
object
Function script section title, specified as an mlreportgen.dom.Paragraph
object. The Paragraph
object contains the title for the
section that contains the MATLAB function code. The default title is the MATLAB
Function block name followed by Function
Script
. For example, for a MATLAB Function block named Covariance Derivative
,
the title is Covariance Derivative Function Script
. The
properties of the paragraph specify the appearance of the title.
To customize the title appearance, modify the properties of the default
Paragraph
object or replace it with another paragraph
object. If you add content to the default or replacement title paragraph,
the content you specify is placed at the front of the default title.
HighlightScriptSyntax
— Whether to highlight script syntax keywords
true
(default) | false
Whether to highlight script syntax keywords, specified as
true
or false
. If the value is
true
, the report uses color to highlight the function
code syntax keywords.
IncludeFunctionSymbolData
— Whether to include function symbol data
false
(default) | true
Whether to include function symbol data, specified as a
true
or false
.
If the value is true
, the report includes information
about the symbols that appear in the main MATLAB function code. If the IncludeSupportingFunctions
property is
true
, the report also contains information about
symbols that appear in the code of the supporting functions. Function symbol
data is reported only if the Object
property of specifies a MATLAB
Function block.
Note
If you include function symbol data, report generation can be slower than if you do not include it.
FunctionSymbolReporter
— Function symbol data reporter
mlreportgen.report.BaseTable
object
Function symbol data reporter, specified as an mlreportgen.report.BaseTable
object. The
MATLABLFunction
reporter uses this reporter to create
tables of the properties of each symbol that appears in the main MATLAB function code and optionally in the supporting functions code.
The symbols in the generated report are grouped by types, which are
variable, operation, and function-call site. The tables for each symbol type
appear after the function properties. The reported function and symbol
properties are listed in the following tables. The default value of this
property is a BaseTable
object with the
TableStyleName
property set to the
MATLABFunctionFunctionSymbolTable
style, which is
defined in the default template for a MATLABFunction
reporter.
Function Properties | Description |
---|---|
Function Name | Name of the function |
Function ID | ID of the function. Simulink assigns a unique ID to every MATLAB Function in a model and to every supporting function. A built-in or user-defined supporting function uses its same ID, regardless of how many functions it supports in a given model. |
Path | Path of the function, which is the model path of the MATLAB Function block or Stateflow block that contains it. The path of a supporting function is the path of the MATLAB file that defines it. |
Variable Properties | Description |
---|---|
Name | Name of the variable |
Data type | Data type and the size of the variable |
Start position | Line and column number of the first character of the variable name in the script in which it appears |
Operation Properties | Description |
---|---|
Name | Character or characters that represent the operation type. For example, + |
Data type | Data type and size of the value produced by the operation |
Start position | Line and column number of the first character of the operation in the script in which it appears |
Function Call Site Properties | Description |
---|---|
Name | Name of the called function |
Data type | Data type and the size of the value returned by the called function |
ID | ID of the called function |
Start position | Line and column number of the first character of the call site in the script in which it appears |
To customize the appearance of the function symbol data tables, customize
the default BaseTable
reporter or replace it with a custom
BaseTable
reporter. If you specify the
Title
property in the default or replacement
BaseTable
reporter, the content is placed at the front of
the default title in the generated report.
IncludeSupportingFunctions
— Whether to include supporting functions
false
(default) | true
If the value is true
, the report includes a list of the
user-defined functions called directly or indirectly by the main function of
the MATLAB Function block being reported.
SupportingFunctionsType
— Supporting function types
{'MATLAB' 'user-defined'}
(default) | cell array of character vectors | string array
Supporting function types to be reported, specified as a cell array of character vectors or a string array. The cell array or string array can specify one or both of these types.
MATLAB
— Include MATLAB supporting functionsuser-defined
— Include user-defined supporting functions
SupportingFunctionsReporter
— Supporting functions reporter
slreportgen.report.BaseTable
Supporting functions reporter, specified as an mlreportgen.report.BaseTable
object. The
BaseTable
object reports the functions invoked directly
or indirectly by the main MATLAB function. The functions are sorted by function name. The
default value of this property is a BaseTable
object with
the TableStyleName
property set to the
MATLABFunctionSupportingFunctionsTable
style, which
is defined in the default template for a MATLABFunction
reporter.
To customize the appearance of the supporting functions table, customize
the default BaseTable
reporter or replace it with a
customized version of the BaseTable
reporter.
IncludeSupportingFunctionsCode
— Whether to include code of user-defined supporting functions
false
(default) | true
Whether to include the code of user-defined supporting functions,
specified as true
or false
. If the
value is true
, the report includes the code for the
user-defined functions called directly or indirectly by the main
function.
SupportingFunctionsCode
— User-defined supporting functions code formatter
mlreportgen.dom.Paragraph
object
User-defined supporting functions code formatter, specified as an mlreportgen.dom.Paragraph
object. The Paragraph
object controls the formatting, such as
the font family, font size, and alignment, of the code in the report. The
MATLABFunction
reporter highlights the syntax of the
function text (code) and appends the highlighted text to the paragraph
object.
To customize the code appearance, modify the properties of the default
Paragraph
reporter or replace the reporter with a custom
reporter. If you add content to the default or replacement
Paragraph
reporter, the content is placed before the
supporting function code in the generated report.
SupportingFunctionsCodeTitle
— User-defined supporting function section title
mlreportgen.dom.Paragraph
User-defined supporting function section title, specified as an mlreportgen.dom.Paragraph
object. The MATLABFunction
reporter uses the formatter to
create a title for each user-defined supporting function. The default value
of this property is an empty paragraph with properties that specify the
appearance of the function title. By default, the
MATLABFunction
reporter appends the supporting function
name to the paragraph. You can customize the title appearance by modifying
the properties of the default paragraph object or by replacing it with
another paragraph object. Any content that you add to the default or
replacement paragraph appears before each title in the generated
report.
TemplateSrc
— Source of template for this reporter
character vector | string scalar | reporter or report | DOM document or document part
Source of the template for this reporter, specified in one of these ways:
Character vector or string scalar that specifies the path of the file that contains the template for this reporter
Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter
Document Object Model (DOM) document or document part whose template is used for this reporter or whose template library contains the template for this reporter
The specified template must be the same type as the report to which you
append this reporter. For example, for a Microsoft® Word report, TemplateSrc
must be a Word reporter template.
If the TemplateSrc
property is empty, this reporter uses the
default reporter template for the output type of the report.
TemplateName
— Name of template for this reporter
character vector | string scalar
Name of the template for this reporter, specified as a character vector or string scalar.
The template for this reporter must be in the template library of the template specified by
the TemplateSrc
property of this reporter.
Data Types: char
| string
LinkTarget
— Hyperlink target for this reporter
[]
(default) | character vector | string scalar | mlreportgen.dom.LinkTarget
object
Hyperlink target for this reporter, specified as a character vector or string scalar
that specifies the link target ID, or an mlreportgen.dom.LinkTarget
object. A character vector or string scalar
value converts to a LinkTarget
object. The link target immediately
precedes the content of this reporter in the output report.
Methods
Public Methods
slreportgen.report.MATLABFunction.createTemplate | Create copy of slreportgen.report.MATLABFunction reporter
template |
slreportgen.report.MATLABFunction.getClassFolder | Get location of folder that contains
slreportgen.report.MATLABFunction class definition
file |
slreportgen.report.MATLABFunction.customizeReporter | Create subclass of slreportgen.report.MATLABFunction
class |
copy | Create copy of a Simulink reporter object and make deep copies of certain property values |
getImpl | Get implementation of reporter |
Examples
Report a MATLAB Function block
To include information about a MATLAB Function block in a report, use an slreportgen.report.MATLABFunction
reporter. By default, the report includes a table of object properties, a table of input and output arguments, and the function script.
import slreportgen.report.* import mlreportgen.report.* model_name = "slrgex_radar_eml"; load_system(model_name); mlfcnObj = "slrgex_radar_eml/MATLAB Function"; rpt = slreportgen.report.Report("MyReport","pdf"); chapter = Chapter(mlfcnObj); rptr = MATLABFunction(mlfcnObj); add(chapter,rptr); add(rpt,chapter); close(rpt); close_system(model_name); rptview(rpt);
Here is the first page of the report:
Include MATLAB Function Argument Details in Report
To include the MATLAB function argument details in a report, use the IncludeArgumentProperties
property of the MATLABFunction
reporter.
import slreportgen.report.* import mlreportgen.report.* model_name = "slrgex_radar_eml"; load_system(model_name); mlfcnObj = "slrgex_radar_eml/MATLAB Function"; rpt = slreportgen.report.Report("myReport","pdf"); chapter = Chapter(mlfcnObj); rptr = MATLABFunction(mlfcnObj); rptr.IncludeArgumentProperties = true; add(chapter,rptr); add(rpt,chapter); close(rpt); close_system(model_name); rptview(rpt);
Here are some of the argument detail tables in the generated report:
Change the MATLAB Function Script Formatting and Title
To customize the title of the function script section, use the FunctionScriptTitle
property. To change the formatting of the code, create a DOM paragraph that specifies the font family, size, and color and assign the paragraph to the FunctionScript
property.
import slreportgen.report.* import mlreportgen.report.* model_name = "slrgex_radar_eml"; load_system(model_name); mlfcnObj = "slrgex_radar_eml/MATLAB Function"; rpt = slreportgen.report.Report("myReport","html"); chapter = Chapter(mlfcnObj); rptr = MATLABFunction(mlfcnObj); paraTitle = mlreportgen.dom.Paragraph("SCRIPT: "); rptr.FunctionScriptTitle = paraTitle; paraScript = mlreportgen.dom.Paragraph; paraScript.FontFamilyName = "Arial"; paraScript.FontSize = "12pt"; paraScript.Color = "blue"; rptr.FunctionScript = paraScript; add(chapter,rptr); add(rpt,chapter); close(rpt); close_system(model_name); rptview(rpt);
Here is a portion of the function script section, which shows the title and some of the code:
Include Code of User-Defined Supporting Functions in Report
By default, a MATLABFunction
reporter includes the code of the main function, but not the code of the user-defined supporting functions that the main function calls. To include the code of the user-defined functions, use the IncludeSupportingFunctionsCode
property.
import slreportgen.report.* import mlreportgen.report.* model_name = "slrgex_stats"; load_system(model_name); mlfcnObj = "slrgex_stats/MATLAB Function"; rpt = slreportgen.report.Report("myReport","pdf"); chapter = Chapter(mlfcnObj); rptr = MATLABFunction(mlfcnObj); rptr.IncludeSupportingFunctionsCode = true; add(chapter,rptr); add(rpt,chapter); close(rpt); close_system(model_name); rptview(rpt);
Here is the MATLAB function script section, which shows the code for both the main function and the user-defined supporting function, avg
.
Version History
Introduced in R2018a
See Also
slreportgen.finder.BlockFinder
| slreportgen.finder.BlockResult
| slreportgen.finder.DiagramElementFinder
| slreportgen.finder.DiagramElementResult
| slreportgen.finder.StateflowDiagramElementFinder
| mlreportgen.report.BaseTable
| mlreportgen.dom.Paragraph
| MATLAB Function | slreportgen.utils.isMATLABFunction
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)