MATLAB Function Reports

When you simulate or build a Simulink® model that contains MATLAB Function blocks, Simulink generates a report for each MATLAB Function block in your model. Use the report to debug your MATLAB® functions and verify that they are suitable for code generation. The report provides type information for the variables and expressions in your functions. This information helps you to find sources of error messages and to understand type propagation rules.

Stateflow® produces one report for each Stateflow chart, regardless of the number of MATLAB functions it contains.

If you have identical MATLAB Function blocks in your model, for example, one in a library and one in the model, a single report is generated for the identical blocks.

Opening a MATLAB Function Report

Use one of these methods:

  • In the MATLAB Function Block Editor, select View Report.

  • If compilation errors occur, in the Diagnostic Viewer window, select the report link.

Error and Warning Messages

View errors and warnings on the All Messages tab. To highlight the source code for an error or warning, click the message. It is best practice to address the first message in the list, because often subsequent errors and warnings are related to the first message.

Functions List

In the MATLAB Source pane, the Function List view organizes functions according to the containing file. To visualize functions according to the call structure, use the Call Tree view.

To view a function in the code pane of the report, click the function. To edit the function, click Edit in MATLAB. A function that is in the MATLAB Function block opens in the MATLAB Function Block Editor. Other functions open in the MATLAB Editor.

MATLAB Source

To view a MATLAB function in the code pane, click the function in the MATLAB Source pane. To see information about the type of a variable or expression, pause over the variable or expression.

In the code pane, syntax highlighting of MATLAB source code helps you to identify MATLAB syntax elements. Syntax highlighting also helps you to identify certain code generation attributes such as whether a function is extrinsic or whether an argument is constant.

Extrinsic Functions

In the MATLAB code, the report identifies an extrinsic function with purple text. The information window indicates that the function is extrinsic.

Constant Arguments

In the MATLAB code, orange text indicates a compile-time constant argument to an entry-point function or a specialized function. The information window includes the constant value.

Knowing the value of the constant arguments helps you to understand generated function signatures. It also helps you to see when code generation created function specializations for different constant argument values.

To export the value to a variable in the workspace, click .

MATLAB Variables

The Variables tab provides information about the variables for the selected MATLAB function. To select a function, click the function in the MATLAB Source pane.

The variables table shows:

  • Class, size, and complexity

  • Properties of fixed-point types

This information helps you to debug errors, such as type mismatch errors, and to understand type propagation.

Visual Indicators on the Variables Tab

This table describes symbols, badges, and other indicators in the variables table.

Column in the Variables TableIndicatorDescription
NameexpanderVariable has elements or properties that you can see by clicking the expander.
Name{:}Heterogeneous cell array (all elements have the same properties)
Name{n}nth element of a heterogeneous cell array
Classv > nv is reused with a different class, size, and complexity. The number n identifies each unique reuse (a reuse with a unique set of properties). When you pause over a renamed variable, the report highlights only the instances of this variable that share the class, size, and complexity. See Reuse the Same Variable with Different Properties.
Size:nVariable-size dimension with an upper bound of n
Size:?Variable-size with no upper bound
SizeitalicsVariable-size array whose dimensions do not change size during execution
Classsparse prefixSparse array
Classcomplex prefixComplex number
Class

Fixed-point type

To see the fixed-point properties, click the badge.

Report Limitations

  • The variables table does not show individual elements of varagin and vargout.

  • The report does not show full information for unrolled loops. It displays data types of one arbitrary iteration.

  • The report does not show information about dead code.

Related Topics