MATLAB: Script based coverage filter creation

coverage filterMATLABmodel coveragesimulinkSimulink Coverage

I am trying to find a way to create coverage filters using command line or scripts. All I can find in the matlab help documentation are sections describing how to use different guis for adding, creating and setting coverage filters ( http://se.mathworks.com/help/slvnv/ug/create-edit-and-view-coverage-filter-rules.html ). But I need to do these actions using a scripts. For example if I want to exclude a certain subsystem from the coverage report I want to be able to do this using a command line function (e g ExcludeFromCoverage('ModelName/SubSystemName'); ).
Is it only possible to use model coverage filters through the GUIs Coverage Setting and Coverage Filter viewer?

Best Answer

Hi Jonatan,
I found an example of this by searching around, but this doesn't seem to be documented. Hopefully this at least helps to get you started with a shipping example, although you may have to play around with the code to figure out how to tailor this for your model.
model = 'slvnvdemo_cv_small_controller';
open_system(model)
ssid = Simulink.ID.getSID('slvnvdemo_cv_small_controller/Saturation')
f = SlCov.FilterEditor.getInstance(model)
props = f.getProperties(ssid)
f.setFilterByProp(props(2),'turn on filter for this block') % the second argument is the description for the filter
f.save('filename')
set_param(model,'CovFilter','filename')
data = cvsim(model)
The other thing is: If you have an existing coverage filter file, you can add it programmatically to a cvtest object using the filter.fileName property. This is listed in the cvtest documentation .
- Sebastian