MATLABFunctionReport - MATLAB function report - MATLAB (original) (raw)
Main Content
MATLAB function report
Since R2021a
Description
Use MATLABFunctionReport
objects to access information about the functions and variables used by MATLAB Function blocks.
Creation
To create a MATLABFunctionReport
object for a MATLAB Function block, call the getReport function on the MATLABFunctionConfiguration object for the block. For example, if the modelmyModel
contains a MATLAB Function block calledMATLAB Function
, enter:
config = get_param("myModel/MATLAB Function", ... "MATLABFunctionConfiguration"); report = getReport(config);
Properties
This property is read-only.
Functions in the MATLAB Function block, specified as an array ofcoder.Function
objects. The array contains onecoder.Function
object for each function in the block. Use these objects to access information such as the name, scope, and type of the variables used by each function. For more information, see coder.Function Properties (MATLAB Coder).
Data Types: coder.Function
Examples
Access the MATLABFunctionConfiguration
object for theMATLAB Function block in the modelcall_stats_block2
described in Implement MATLAB Functions in Simulink with MATLAB Function Blocks.
config = get_param("call_stats_block2/MATLAB Function", ... "MATLABFunctionConfiguration");
Create the MATLABFunctionReport
object for the MATLAB Function block.
report = getReport(config);
Access the coder.Function
objects in the report.
functions = report.Functions;
Create a custom report that lists the functions and variables in the MATLAB Function block.
for i = 1:numel(functions) fprintf("Function %s uses these variables:\n",functions(i).Name) variables = functions(i).Variables; for j = 1:numel(variables) fprintf("%d. %s -- %s\n",j,variables(j).Name,variables(j).Scope) end fprintf("\n") end
Function stats uses these variables:
- mean -- Output
- stdev -- Output
- vals -- Input
- len -- Local
Function avg uses these variables:
- mean -- Output
- array -- Input
- size -- Input
Tips
The first time that you create aMATLABFunctionReport
object or 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 generate a newMATLABFunctionReport
object. Otherwise, the object does not reflect your changes. From the Modeling tab, select Update Model, or use the Ctrl+D keyboard shortcut. If you are in theMATLAB Function Block Editor, update the model by using theCtrl+Shift+D keyboard shortcut instead.
Version History
Introduced in R2021a