When you build a Simulink® model that contains MATLAB Function blocks, Simulink generates a report in HTML format for each MATLAB Function block in your model. You can use the report to debug your MATLAB® functions and verify that they are suitable for code generation. The report provides links to your MATLAB functions and compile-time type information for the variables and expressions in these functions. If your model fails to build, this information simplifies finding sources of error messages and aids understanding of type propagation rules.
Note: If you have a Stateflow® license, there is one report for each Stateflow chart, regardless of the number of MATLAB functions it contains.
Note: 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.
Use one of the following methods:
In the MATLAB Function Block Editor, select View Report.
If compilation errors occur, in the Diagnostic
Viewer window, select the
When you build the MATLAB function, the code generation software generates an HTML report. The report provides the following information, as applicable:
MATLAB code information, including a list of all functions and their compilation status
Call stack information, providing information on the nesting of function calls
Summary of compilation results, including type of target and number of warnings or errors
List of error and warning messages
List of variables in your MATLAB function
To view your MATLAB function code, click the MATLAB code tab. The report displays the MATLAB code for the function highlighted in the list on this tab.
The MATLAB code tab provides:
A list of the MATLAB functions that have been compiled. The report displays icons next to each function name to indicate whether compilation was successful:
Errors in function.
Warnings in function.
Successful compilation, no errors or warnings.
A filter control that you can use to sort your functions by:
The report annotates the local function with the name of the parent function in the list of functions on the MATLAB code tab.
For example, if the MATLAB function
the local function
the local function
subfcn2, the report displays:
fcn1 > subfcn1 fcn2 > subfcn2
If your MATLAB function calls the same function with different types of inputs, the report numbers each of these specializations in the list of functions on the MATLAB code tab.
For example, if the function
fcn calls the
subfcn with different types of inputs:
function y = fcn(u) % Specializations y = y + subfcn(single(u)); y = y + subfcn(double(u));
fcn > subfcn > 1 fcn > subfcn > 2
The report provides call stack information:
On the Call stack tab.
In the list of Callers.
If a function is called from more than one function, this list provides details of each call site. Otherwise, the list is disabled.
To view call stack information, click the Call stack tab. The call stack lists the functions in the order that the top-level function calls them. It also lists the local functions that each function calls.
If a function is called from more than one function, this list provides details of each call site. To navigate between call sites, select a call site from the Callers list. If the function is not called more than once, this list is disabled.
To view a summary of the compilation results, including type of target and number of errors or warnings, click the Summary tab.
The report provides information about errors and warnings. If errors occur during simulation of a Simulink model, simulation stops. If warnings occur, but no errors, simulation of the model continues.
The report provides information about warnings and errors by listing all errors and warnings in chronological order in the All Messages tab.
If errors or warnings occurred during compilation, click the All Messages tab to view a complete list of these messages. The report lists the messages in the order that the compiler detects them. It is best practice to address the first message in the list, because often subsequent errors and warnings are related to the first message.
To locate the offending line of code for an error or warning in the list, click the message in the list. The report highlights errors in the list and MATLAB code in red and warnings in orange. Click the blue line number next to the offending line of code in the MATLAB code pane to go to the error in the source file.
Note: You can fix errors only in the source file.
If errors or warnings occurred during compilation, the report underlines them in your MATLAB code. The report underlines errors in red and warnings in orange. To learn more about a particular error or warning, place your pointer over the underlined text.
The report provides compile-time type information for the variables and expressions in your MATLAB code, including name, type, size, complexity, and class. It also provides type information for fixed-point data types, including word length and fraction length. You can use this type information to find the sources of error messages and to understand type propagation rules.
You can view information about the variables in your MATLAB code:
On the Variables tab, view the list.
In your MATLAB code, place your cursor over the variable name.
In the MATLAB code, an orange variable name indicates a compile-time constant argument to a specialized function. The information for a constant argument includes the value. This information helps you to see when code generation created function specializations for different constant argument values.
To view a list of the variables in your MATLAB function, click the Variables tab. The report displays a complete list of variables in the order that they appear in the function that you selected on the MATLAB code tab. Clicking a variable in the list highlights instances of that variable, and scrolls the MATLAB code pane so that you can view the first instance.
As applicable, the report provides the following information about each variable:
DataTypeMode (DT mode) — for fixed-point data types only. For more information, see Data Type and Scaling Properties.
Signed — sign information for built-in data types, signedness information for fixed-point data types.
Word length (WL) — for fixed-point data types only.
Fraction length (FL) — for fixed-point data types only.
Note: For more information on viewing fixed-point data types, see Use Fixed-Point Code Generation Reports.
The report displays a column only if at least one variable in the code has information in that column. For example, if the code does not contain fixed-point data types, the report does not display the DT mode, WL, or FL columns.
Sorting Variables on the Variables Tab. By default, the report lists the variables in the order that they appear in the selected function.
To sort the variables, click the column headings on the Variables tab. To sort the variables by multiple columns, hold down the Shift key when you click the column headings.
To restore the list to the original order, click the Order column heading.
Structures on the Variables Tab. To display structure field properties, expand the structure on the Variables tab.
If you sort the variables by type, size, complexity, or class, it is possible that a structure and its fields do not appear sequentially in the list. To restore the list to the original order, click the Order column heading.
Variable-Size Arrays in the Variables Tab. For variable-size arrays, the Size field
includes information about the computed maximum size of the array.
The size of each array dimension that varies is prefixed with a colon
:. The size of an unbounded
In the following report, variables
variable-size. The second dimension of
A has a
maximum size of 100. The size of the second dimension of
If you declare a variable-size array, and then fix the dimensions
of this array in the code, the report appends
the size of the variable. In the generated C code, this variable appears
as a variable-size array, but the sizes of its dimensions do not change
For information about how to use the size information for variable-size arrays, see Variable-Size Data Definition for Code Generation.
Renamed Variables in the Variables Tab. If your MATLAB function reuses a variable with a different size, type, or complexity, the code generator attempts to create separate, uniquely named variables. For more information, see Reuse the Same Variable with Different Properties. The report numbers the renamed variables in the list on the Variables tab. When you place your cursor over a renamed variable, the report highlights only the instances of this variable that share data type, size, and complexity.
For example, suppose that your code uses the variable
hold a scalar double, and reuses it outside the for-loop to hold a
vector of doubles. In the list on the Variables tab,
the report displays two variables,
To view information about a particular variable or expression in your MATLAB function code, on the MATLAB code pane, place your cursor over the variable name or expression. The report highlights variables and expressions in different colors:
Green, when the variable has data type information at this location in the code
For variable-size arrays, the Size field
includes information on the computed maximum size of the array. The
size of each array dimension that varies is prefixed with a colon
Green with orange text, when a constant argument has data type and value information. When the variable is a compile-time constant argument to a specialized function:
The variable name is orange.
The information for the variable includes the value.
If you export the value as a variable to the base workspace, you can use the Workspace browser to view detailed information about the variable.
To export the value to the base workspace:
Click the Value link.
In the Export Constant Value dialog box, specify the Variable name.
The variable and its value appear in the Workspace browser.
Pink, when the variable has no data type information
Purple, information about expressions. You can also view information about expressions in your MATLAB code. On the MATLAB code pane, place your cursor over an expression. The report highlights expressions in purple and provides more detailed information.
Red, when there is error information
You can use keyboard shortcuts settings to perform actions in the report.
This table lists actions that you can associate with a keyboard shortcut. The keyboard shortcuts are defined in your MATLAB preferences. See Define Keyboard Shortcuts.
|Action||Default Keyboard Shortcut for a Windows® Platform|
|Evaluate selected MATLAB code||F9|
|Open help for selected MATLAB code||F1|
|Open selected MATLAB code||Ctrl+D|
|Step backward through files that you opened in the code pane||Alt+Left|
|Step forward through files that you opened in the code pane||Alt+Right|
Alternatively, you can select these actions from a context menu. To open the context menu, right-click anywhere in the report.
This table lists keyboard shortcuts that help you navigate between panes and tabs in the code generation report. To advance through data in the selected pane, use the Tab key. These keyboard shortcuts override the keyboard shortcut settings in your MATLAB preferences. See Define Keyboard Shortcuts.
|MATLAB code tab||Ctrl+M|
|Call stack tab||Ctrl+K|
|All Messages Tab||Ctrl+A|
Use the keyboard shortcut associated with
your MATLAB preferences. The default keyboard shortcut for
a Windows platform is Ctrl+F.
The report displays information about the variables and expressions in your MATLAB code with the following limitations: