Skip to Main Content Skip to Search
Product Documentation

Working with MATLAB Function Reports

About MATLAB Function Reports

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.

Location of MATLAB Function Reports

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/

Opening MATLAB Function Reports

Use one of the following methods:

Description of MATLAB Function Reports

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:

Viewing Your MATLAB Function Code

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:

Viewing Subfunctions

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

Viewing Specializations

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

Viewing Call Stack Information

The report provides call stack information:

Viewing Call Stack Information on the Call Stack Tab

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.

Viewing Function Call Sites in the Callers List

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.

Viewing the Compilation Summary Information

To view a summary of the compilation results, including type of target and number of errors or warnings, click the Summary tab.

Viewing Error and Warning Messages

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:

Viewing Errors and Warnings 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. 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.

Viewing Error and Warning Information in Your MATLAB Code

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.

Viewing Variables in Your MATLAB Code

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:

Viewing Variables in the Variables Tab

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.

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.

Viewing Information About Variables and Expressions in Your MATLAB Function Code

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.

Keyboard Shortcuts for the MATLAB Function Report

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 TabCtrl+m
Call Stack TabCtrl+k
MATLAB Code Pane Ctrl+w
Summary TabCtrl+s
All Messages TabCtrl+a
Variables TabCtrl+v

Report Limitations

The report displays information about the variables and expressions in your MATLAB code with the following limitations:

 varargin and varargout

 Loop Unrolling

 Dead Code

 Structures

 Column Headings on Variables Tab

 Multiline Matrices

  


Related Products & Applications

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