Determine if function is suitable for code generation
coder.screener( analyzes the entry-point
fcn to identify unsupported functions and
language features as code generation compliance issues. The code generation compliance
issues are displayed in the readiness report.
fcn calls other functions directly or indirectly that are not
MathWorks® functions (MATLAB built-in functions and toolbox functions),
analyzes these functions. It does not analyze the MathWorks functions.
It is possible that
coder.screener does not detect
all code generation issues. Under certain circumstances,
it is possible that
coder.screener reports false errors.
To avoid undetected code generation issues and false errors, before generating code, verify that your MATLAB code is suitable for code generation by performing these additional checks:
coder.screener, fix issues that the Code
coder.screener, and before generating C/C++ code,
verify that your MATLAB code is suitable for code generation by generating and verifying a MEX
coder.screener function does not report functions that the code
generator treats as extrinsic. Examples of such functions are
figure. See Extrinsic Functions.
coder.screener function identifies calls to
functions that are not supported for code generation. It checks the entry-point function,
foo1, and the function,
Write the function
foo2 and save it in the file
function out = foo2(in) out = eval(in); end
Write the function
foo1 that calls
foo1 in the file
function out = foo1(in) out = foo2(in); disp(out); end
The Code Generation Readiness report displays a summary of the unsupported
MATLAB function calls. The report Summary tab indicates that
foo2.m contains one call to the
which is not supported for code generation.
In the report, click the Code Structure tab and select the Show MATLAB functions check box.
This tab displays a pie chart showing the relative size of each file and how suitable each file is for code generation. The report displays:
Green: Function (
foo1.m) suitable for code
Yellow: Function (
foo2.m) requires significant
The report also displays a Call Tree with Code
Generation Readiness Score. The score is based on a scale of 1–5. 1
indicates that significant changes are required. 5 indicates that the code generation
readiness tool does not detect issues. In this example, the report assigns
foo1.m a code generation readiness score of 4 and
foo2.m a score of 3.
foo2 calls one unsupported MATLAB function. To generate a MEX function for
the code to make the call to
eval extrinsic, and then rerun the
code generation readiness tool.
eval to extrinsic by using the
function out = foo2(in) coder.extrinsic('eval'); out = eval(in); end
The report no longer flags that code generation
does not support the
eval function. When you generate a MEX
foo1, the code generator dispatches
eval to MATLAB for execution. For standalone code generation, the code generator does not
generate code for
coder.screener function identifies
MATLAB data types that code generation does not support.
Write the function
myfun1 that contains a MATLAB calendar duration array data
function out = myfun1(A) out = calyears(A); end
The code generation readiness report indicates that the
data type is not supported for code generation.
The report assigns
myfun1 a code generation readiness score of
3. Before generating code, fix the reported issues.
fcn— Name of entry-point function
Name of entry-point MATLAB function for analysis. Specify as a character vector or a string scalar.
fcn_1,...,fcn_n— List of entry-point function names
Comma-separated list of entry-point MATLAB function names for analysis. Specify as character vectors or string scalars.