MATLAB: How to generate an Excel file from a Simulink Coverage object

coverageexcelsimulinkSimulink Check

I am using 'cvsim' and 'cvhtml' in the Command Window to generate Simulink coverage reports. Is there a way to generate an Excel file with a list of model elements missing coverage?

Best Answer

As of MATLAB R2020b, this is not possible, but you may be able to circumvent this limitation by writing a script.
Specifically, the '*info' functions (i.e. decisioninfoconditioninfomcdcinfo, etc.) allow you to query coverage information from the 'cvdata' object and can be used to check if a specified block or model object is missing coverage.
A possible workaround would be to:
  • Get a list of all of the blocks in the model using find_system
  • Iterate over the list of blocks and for each, check the block's coverage using 'decisioninfo', 'conditioninfo', 'mcdcinfo', etc. (depending on what metrics you are interested in)
    • In most cases, the *info function will return empty, meaning that this metric is not relevant for that block and this can be ignored.
    • Otherwise, the function will return a two-element array showing the number of satisfied outcomes and the number total outcomes. If the former is less than the latter, then the block is missing coverage, and this can be logged as you see fit.