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 tf = foo2(source,target) G = digraph(source,target); tf = isdag(G); end
Write the function
foo1 that calls
foo1 in the file
function tf = foo1(source,target) assert(numel(source)==numel(target)) tf = foo2(source,target); 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
digraph function and one call to the
isdag function, which are 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 two unsupported MATLAB functions. To generate a MEX function, modify the code to make the calls
isdag extrinsic by using the
coder.extrinsic (MATLAB Coder) directive, and then rerun
the code generation readiness tool.
function tf = foo2(source,target) coder.extrinsic('digraph','isdag'); G = digraph(source,target); tf = isdag(G); end
coder.screener on the entry-point function
The report no longer flags that code generation
does not support the
When you generate a MEX function for
foo1, the code generator
dispatches these two functions to MATLAB for execution.
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.
coder.extrinsic (MATLAB Coder)