Main Content

MATLAB Function Reports

When you simulate, update, or generate code from a Simulink® model that contains MATLAB Function blocks or Stateflow® charts with MATLAB® functions, Simulink generates a report for each MATLAB function in your model. The report provides type information for the variables and expressions in your functions, which can help you find the sources of errors and warnings.

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, a single report is generated for the identical blocks.

Open a MATLAB Function Report

To open a MATLAB function report, use one of these methods:

Note

The first time that you open the MATLAB function report, Simulink automatically updates your model. If you make subsequent changes to the MATLAB code in the block, you must update your model before you reopen the report. Otherwise, the report does not reflect your changes. From the Modeling tab, select Update Model, or use the Ctrl+D keyboard shortcut. If you are in the MATLAB Function Block Editor, update the model by using the Ctrl+Shift+D keyboard shortcut instead.

Analyze MATLAB Source Code

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

The MATLAB function report is read-only. To edit a function, select the name of the function in the MATLAB Source pane and click Open in Editor.

To view a MATLAB function in the code pane, click the name of the function in the MATLAB Source pane. In the code pane, when you pause on a variable or expression, a tooltip displays information about its size, type, and complexity. Additionally, syntax highlighting helps you to identify MATLAB syntax elements and certain code generation attributes, such as whether a function is extrinsic or whether an argument is constant.

Extrinsic Functions

The report identifies an extrinsic function with purple text. The tooltip indicates that the function is extrinsic.

This image shows the report when it identifies the extrinsic function. The extrinsic function is purple.

Constant Arguments

Orange text indicates a compile-time constant argument to an entry-point function or a specialized function. The tooltip includes the constant value.

This image shows the report when it identifies a compile-time costant argument. The constant a is highlighted in orange.

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

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

View Error and Warning Messages

To view errors and warnings, in the bottom pane of the report, open the All Messages tab. To highlight the source code for an error or warning, click the message. It is a best practice to address the first message in the list because subsequent errors and warnings are often related to the first message.

View MATLAB Variables

To view information about the variables for the selected MATLAB function, in the bottom pane of the report, open the Variables tab.

The variables table shows:

  • Class, size, and complexity

  • Properties of fixed-point types

This information helps you to understand type propagation and identify type mismatch errors.

Visual Indicators on the Variables Tab

This table describes the 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{:}Homogenous 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 a reuse with a unique set of properties. When you pause on 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 array with an upper bound of n.
Size:?Variable-size array 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 the individual elements of varargin and varargout.

  • 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.

See Also

| | | | |

Related Topics