Main Content

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.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

reporter = slreportgen.report.MATLABFunction creates an empty MATLABFunction reporter based on the default template. Use the Object property to specify the Simulink MATLAB Function block or Stateflow MATLAB function to report.

reporter = slreportgen.report.MATLABFunction(mlfcnObj) sets the Object property to the MATLAB Function block or Stateflow MATLAB function specified by mlfcnObj.

example

reporter = MATLABFunction(Name=Value) sets MATLABFunction reporter properties using name-value pairs. You can specify multiple name-value pair arguments in any order.

Properties

expand all

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.

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.

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.

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.

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

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.

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.

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.

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.

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.

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.

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.

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.

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 PropertiesDescription
Function NameName of the function
Function IDID 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.
PathPath 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 PropertiesDescription
NameName of the variable
Data typeData type and the size of the variable
Start positionLine and column number of the first character of the variable name in the script in which it appears

Operation PropertiesDescription
NameCharacter or characters that represent the operation type. For example, +
Data typeData type and size of the value produced by the operation
Start positionLine and column number of the first character of the operation in the script in which it appears

Function Call Site PropertiesDescription
NameName of the called function
Data typeData type and the size of the value returned by the called function
IDID of the called function
Start positionLine 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.

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.

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 functions

  • user-defined— Include user-defined supporting functions

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.

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.

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.

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.

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.

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

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

expand all

Examples

collapse all

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:

scrn1.png

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:

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:

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