| Contents | Index |
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:
Click the Open MATLAB Function Report
icon in the MATLAB Function
Block Editor.
Select Tools > Open MATLAB Function Report from the MATLAB Function Block Editor toolbar.
Click the report link in the Diagnostics Manager window if compilation errors occur.

When you build the MATLAB function, the code generation software generates an HTML report. The following example shows a successful compilation:

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, Filter function list by attributes, that you can use to sort your functions by:
Size
Complexity
Class
The report annotates the subfunction 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 subfunction subfcn and fcn2 contains the subfunction 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 subfunctions 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.
Highlighting all errors and warnings in the MATLAB code pane
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. The report marks messages as follows:
|
| Error |
|
| Warning |
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 pointer over the variable name
To view a list of all 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 selected on the MATLAB code tab. Clicking a variable in the list highlights all instances of that variable, and scrolls the MATLAB code pane so that you can view the first instance.
The report provides the following information about each variable, as applicable.
Order
Name
Type
Size
Complexity
Class
DataTypeMode (DT mode) — for fixed-point data types only. For more information, see DataTypeMode in the Fixed-Point Toolbox documentation.
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 Working with Fixed-Point Code Generation Reports in the Fixed-Point Toolbox documentation. |
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 any fixed-point data types, the report does not display the DT mode, WL or FL columns.
Sorting Variables in the Variables Tab. By default, the report lists the variables in the order that they appear in the selected function.
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.
Viewing Structures on the Variables Tab. You can expand structures listed on the Variables tab to display the field properties.

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 How Working with Variable-Size Data Is Different for Code Generation in the Code Generation from MATLAB documentation.
Viewing Renamed Variables in the Variables Tab. If your MATLAB function reuses a variable with different size, type, or complexity, whenever possible, the code generation software creates separate, uniquely named variables in the generated code. For more information, see Reusing the Same Variable with Different Properties in the Code Generation from MATLAB documentation. 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.

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:
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 :. Here the array A is variable-sized with a maximum computed size of 1 x 100.

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 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.
| To select ... | Use... |
|---|---|
| MATLAB Code Tab | Ctrl+m |
| Call Stack Tab | Ctrl+k |
| MATLAB Code Pane | Ctrl+w |
| Summary Tab | Ctrl+s |
| All Messages Tab | Ctrl+a |
| Variables Tab | Ctrl+v |
The report displays information about the variables and expressions in your MATLAB code with the following limitations:
Column Headings on Variables Tab
![]() | MATLAB Function Block Editor | Typing Function Arguments | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |