User`s guide
Model Coverage for C and C++ S-Functions
18-37
Model Coverage for C and C++ S-Functions
Model coverage is supported for C/C++ S-Functions. The coverage results for S-Function
blocks can be viewed in the same report as the rest of the model. For each S-Function
block, the report links to a detailed coverage report for the C/C++ code in the block.
To generate coverage report for S-Functions:
1
When creating S-Functions, enable support for coverage.
2
When generating coverage report, enable support for S-Functions.
In this section...
“Make S-Function Compatible with Model Coverage” on page 18-37
“Generate Coverage Report for S-Function” on page 18-38
Make S-Function Compatible with Model Coverage
If you use the legacy_code function, S-Function Builder block or mex function to create
your S-Functions, adapt your method appropriately to make the S-Function compatible
with model coverage.
For more information on the three approaches, see “Creating C MEX S-Functions”.
• “S-Function Using legacy_code Function” on page 18-37
• “S-Function Using S-Function Builder” on page 18-38
• “S-Function Using mex Function” on page 18-38
S-Function Using legacy_code Function
1
Initialize a MATLAB structure with fields that represent Legacy Code Tool
properties.
def = legacy_code('initialize')
2
To enable model coverage, turn on the option def.Options.supportCoverage.
def.Options.supportCoverage = true;
3
Use the structure def in the usual way to generate an S-function. For an example,
see “Coverage for S-Functions”.