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:
Open the MATLAB function. On the Function tab, click Function Report.
Simulate or update the model. If a compilation error occurs, in the Diagnostic Viewer window, select the
For MATLAB Function blocks, call the
openReportfunction on the
MATLABFunctionConfigurationobject associated with the block. For more information, see Programmatically Access MATLAB Function Reports.
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. For more information, see Update Diagram and Run Simulation.
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.
The report identifies an extrinsic function with purple text. The tooltip indicates that the function is extrinsic.
Orange text indicates a compile-time constant argument to an entry-point function or a specialized function. The tooltip includes the constant value.
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 Table||Indicator||Description|
|Name||expander||Variable has elements or properties that you can see by clicking the expander.|
|Name||Homogenous cell array (all elements have the same properties).|
|Size||Variable-size array with an upper bound of
|Size||Variable-size array with no upper bound.|
|Size||italics||Variable-size array whose dimensions do not change size during execution.|
To see the fixed-point properties, click the badge.