slreportgen.report.MATLABFunction class

Package: slreportgen.report
Superclasses:

MATLAB Function block or Stateflow MATLAB function reporter

Description

Create a MATLAB Function block or Stateflow® MATLAB® function reporter.

Note

To use a MATLABFunction reporter in a report, you must create the report using the slreportgen.report.Report class.

Construction

reporter = MATLABFunction() creates an empty MATLABFunction reporter based on a default template. Use its properties to specify the Simulink® MATLAB Function block or a Stateflow MATLAB function on which to report and specify report options.

reporter = MATLABFunction(mlfcnobj) creates a MATLABFunction reporter for the specified mlfcnobj. This reporter adds this default information to the generated report:

  • Simulink MATLAB Function block properties or Stateflow MATLAB function properties, depending on whether the MATLAB function is a block or object

  • Function input and output argument summary

  • MATLAB code used by the MATLAB 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 information.

reporter = MATLABFunction(Name,Value) sets MATLABFunction reporter properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

Input Arguments

expand all

See the Object property.

Properties

expand all

Simulink MATLAB function block or Stateflow MATLAB function whose properties to report, specified as a path or handle.

Note

If you use a finder to find a Lookup Table block and add it directly to a report, this LookupTable reporter is used rather than a Simulink object property reporter.

Whether to include object properties, specified as a logical. If true, the report includes a table of the properties of a MATLAB function. If false, the property table is not included.

Object properties reporter, specified as a BaseTable reporter or a custom reporter. The MATLABFunction reporter uses the specified reporter to create a table of the properties of the MATLAB function. The properties to be reported depend on whether the MATLAB function is a Simulink MATLAB Function block or a Stateflow MATLAB function.

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 a logical. If true, the report includes a summary table of the argument properties of the MATLAB Function. If false, the report does not include an argument summary table.

Argument properties to include in the MATLAB Function argument summary table, specified as a cell array of property name character vectors. The default properties included in the summary are Name, Scope, Port, Compiled Type, and Compiiled Size. If the model is not already compiled, the MATLABFunction reporter compiles the model to obtain Compile Type and Compiled Size data. When the report is closed, the model is uncompiled.

The value of this property can be any combination of these MATLAB Function argument 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 a BaseTable reporter or a custom reporter. The MATLABFunction reporter uses the specified reporter to create a table of the arguments of the MATLAB function. The table includes a summary of arguments and the argument properties specified by ArgumentSummaryProperties.

To customize the appearance of the argument summary table and the content of its title, customize the default BaseTable reporter or replace it with a custom version of the BaseTable reporter.

Whether to include a property table with detailed information for each argument, specified as a logical. If false, the report does not include a property table for each argument in the MATLAB function. If true, the report includes the property table, and 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 a BaseTable reporter or a custom reporter. The MATLABFunction reporter uses the specified reporter to create a table of the argument properties of the MATLAB function. The MATLABFunction reporter creates and uses a copy of this reporter for each argument property to be reported.

To customize the appearance of the argument property table, customize the default BaseTable reporter or replace it with a customized version of the BaseTable reporter.

Whether to include the function script, specified as a logical. If true, the report includes the MATLAB function script that computes the output of the MATLAB Function block from its inputs. If false, the report does not include the function script.

Function script code format, specified as an mlreportgen.dom.Paragraph paragraph. To customize the function script format, such as the font family, font size, alignment, and other attributes, set its mlreportgen.dom.Paragraph properties. The mlreportgen.dom.Paragraph does not control whether the reporter uses colors to highlight script syntax. See the HighlightScriptSyntax to control the highlighting.

To customize the appearance of the script, modify the properties of the default paragraph or replace the paragraph with another paragraph object. If you add content to the default or replacement paragraph, that content is placed before the MATLAB Function script in the generated report.

Function script title, specified as an mlreportgen.dom.Paragraph, which contains the title for the section that contains the MATLAB function script. The default title is the MATLAB Function block name followed by "Function Script," which is appended to the paragraph. 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 script 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.

Highlight script syntax keywords, specified as a logical. If true, the report uses colors to highlight script syntax keywords. If false, the report does not highlight keywords.

Whether to include function symbol data, specified as a logical.

If false, the report does not include information about the symbols that appear in the main MATLAB function script. If true, the report includes the symbol data information. If the IncludeSupportingFunctions property is also true, the report also contains information on symbols that appear in supporting functions. Function symbol data is reported only if the source Object property of this reporter is a Simulink 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. This reporter is the basis for reporting the properties of symbols that appear in the main script of the MATLAB function. The symbols in the generated report are grouped by types, which are variable, operation, and function-call site. The table that lists each symbol type appears after the function properties. The symbol tables list all the symbols of particular types that appear in the main function or specific supporting functions. The report includes supporting function symbols only if IncludeSupportingFunctions is true. The MATLABFunction reporter creates a copy of this reporter for each symbol to be reported and uses the copy to report on the symbol properties. The reported function and symbol properties are:

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
TypeCharacter 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 customized version of the BaseTable reporter. If you specify Title property content in the default or replacement BaseTable reporter, that content is placed at the front of the default title in the generated report.

Whether to include supporting functions, specified as a logical. If false, the report does not include a list of functions invoked directly or indirectly by the function script. If true, the report includes the supporting functions.

Supporting function types to be reported, specified as a cell array. The cell array can include one or both of these character vectors.

  • 'MATLAB' — Include only MATLAB supporting functions

  • 'user-defined' — Include only user-defined supporting functions

Supporting functions reporter, specified as an BaseTable, which lists the functions invoked directly or indirectly by the MATLAB function script. The functions are sorted by function name.

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.

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

  • Reporter or report whose template is used as the template for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used as the template for this reporter or whose template library contains the template for this reporter

The specified template must be of the same type as the report to which this reporter is appended. For example, for a 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 template for this reporter, specified as a string or character array. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string or character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Methods

createTemplateCreate MATLAB Function reporter template
customizeReporterCreate custom MATLAB Function reporter class
getClassFolderMATLAB Function reporter class definition file location

Inherited Methods

getImplGet implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Add MATLAB Function Properties, Arguments, and Function Script

Create a PDF report generator that uses the MATLABFunction reporter. This reporter includes information about the MATLAB Function block in the sldemo_radar_eml model.. The report, by default, 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 = 'sldemo_radar_eml';
load_system(model_name); 
mlfcnobj = 'sldemo_radar_eml/MATLAB Function';

rpt = slreportgen.report.Report('output','pdf');
chapter = Chapter(mlfcnobj); 
rptr = MATLABFunction(mlfcnobj); 
add(chapter,rptr); 
add(rpt,chapter); 

close(rpt); 
close_system(model_name);
rptview(rpt);

The first page of the generated report is shown.

Add MATLAB Function Argument Details

Create an HTML report generator that uses the MATLABFunction reporter and includes MATLAB Function argument details. Use the IncludeArgumentProperties property to include a table for each MATLAB Function block input and output argument. This example uses the sldemo_radar_eml model.

import slreportgen.report.*
import mlreportgen.report.*

model_name = 'sldemo_radar_eml';
load_system(model_name); 
mlfcnobj = 'sldemo_radar_eml/MATLAB Function';

rpt = slreportgen.report.Report('output','html');
chapter = Chapter(mlfcnobj); 
rptr = MATLABFunction(mlfcnobj);
rptr.IncludeArgumentProperties = true;

add(chapter,rptr); 
add(rpt,chapter); 

close(rpt); 
close_system(model_name);
rptview(rpt);

This portion of the generated report shows some of the argument detail tables.

Change the MATLAB Function Script Formatting and Title

Create an HTML report generator that uses the MATLABFunction reporter and sets the appearance of the function script and title. Change the appearance of the MATLAB Function block function script section of the report. Use the FunctionScriptTitle property to specify the text to add at the front of the default function script table title. Create and use a DOM paragraph to change the font, font size, and color of the script. This example uses the sldemo_radar_eml model.

import slreportgen.report.*
import mlreportgen.report.*

model_name = 'sldemo_radar_eml';
load_system(model_name); 
mlfcnobj = 'sldemo_radar_eml/MATLAB Function';

rpt = slreportgen.report.Report('output','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);

This section of the generated report shows "SCRIPT:" added to the title and 12pt Arial blue font.

Introduced in R2018a