|On this page…|
Whenever you build a Simulink® model that contains MATLAB Function blocks, Simulink automatically generates a report in HTML format for each MATLAB Function block in your model. The report helps you 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.
The code generation software provides a report for each MATLAB Function block in the model model_name at the following location:
slprj/_sfprj/ model_name/_self/ sfun/html/
Use one of the following methods:
In the MATLAB Function Block Editor, select View Report.
In the Simulation Diagnostics window, select the report link if compilation errors occur.
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 all error and warning messages
List of all 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 fcn1 contains the local function subfcn and fcn2 contains 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 function subfcn with different types of inputs:
function y = fcn(u) %#codegen % Specializations y = y + subfcn(single(u)); y = y + subfcn(double(u));
The report numbers the specializations in the list of functions.
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.
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 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 an entry-point or a specialized function. The information for these variables includes the value. You can use this information to understand the function signature. You can also use this information to see when code generation created specializations of a function with 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.
It only displays a column 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.
You can sort the variables by clicking the column headings on the Variables tab. To sort the variables by multiple columns, hold down the Shift key when clicking the column headings.
To restore the list to the original order, click the Order column heading.
If you sort the variables by type, size, complexity or class, a structure and its fields might not appear sequentially in the list. To restore the list to the original order, click the Order column heading.
Viewing Information About Variable-Size Arrays in the Variables Tab. 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 :.
In the following report, variable A is variable-size. Its maximum computed size is 1×100.
If the code generation software cannot compute the maximum size of a variable-size array, the report displays the size as :?.
If you declare a variable-size array and then subsequently fix the dimensions of this array in the code, the report appends * to the size of the variable. In the generated C code, this variable appears as a variable-size array, but the size of its dimensions do not change during execution.
For more information on how to use the size information for variable-sized arrays, see Variable-Size Data Definition for Code Generation.
Viewing Renamed Variables in the Variables Tab. If your MATLAB function reuses a variable with different size, type, or complexity, the code generation software attempts to create separate, uniquely named variables in the generated code. 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 pointer over a renamed variable, the report highlights only the instances of this variable that share the same data type, size, and complexity.
For example, suppose your code uses the variable t in a for-loop to hold a scalar double, and reuses it outside the for-loop to hold a 5x5 matrix. The report displays two variables, t>1 and t>2 in the list on the Variables tab.
Viewing Simulation Minimum and Maximum Values in the Variables Tab. If you have a Fixed-Point Designer™ license, and you simulate your model using the Fixed-Point Tool set up to log the minimum and maximum values, you can view these values in the MATLAB Function Report. For more information, see Log Simulation Ranges for MATLAB Function Block.
To view information about a particular variable or expression in your MATLAB function code, on the MATLAB code pane, place your pointer over the variable name or expression. The report highlights variables and expressions in different colors:
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 :. Here the array A is variable-sized with a maximum computed size of 1 x 100.
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.
Purple, information about expressions. You can also view information about expressions in your MATLAB code. On the MATLAB code pane, place your pointer over an expression . The report highlights expressions in purple and provides more detailed information.
Red, when there is error information for an expression. If the code generation software cannot compute the maximum size of a variable-size array, the report underlines the variable name and provides error information.
You can use the following keyboard shortcuts to navigate between the different panes in the MATLAB Function report. Once you have selected a pane, use the Tab key to advance through data in that pane.
|MATLAB Code Tab||Ctrl+m|
|Call Stack Tab||Ctrl+k|
|MATLAB Code Pane||Ctrl+w|
|All Messages Tab||Ctrl+a|