MATLAB: How to calculate Simulink Test coverage percentage from the command line

simulink test

I am using command line methods for Simulink Test rather than using the test manager (sltestmgr). In the test manager, it is easy to view the coverage results percentage. How can I view the percentage from the command line? If I have a results object, ro [results=run(testManagerFile)], then I can access the coverage results in the following way:
>>ro.CoverageResults
But there doesn't seem to be a property for the coverage percentage

Best Answer

ro.CoverageResults returns a cvdata object. There are methods that you can use with a cvdata object for purposes such as this:
For instance, if you would like to calculate the MCDC coverage, then you can use the 'mdcinfo' method in the following way:
cov = mcdcinfo(ro.CoverageResults, 'model_name')
%Percentage of MCDC outcomes covered
percent_cov = 100 * cov(1) / cov(2)
The 'mcdcinfo' documentation: