I came here hoping to find an answer to this question, but unfortunately there isn't one yet.
The only solution I can come up with right now is to instead use CodeCoveragePlugin.forFile to explicitly list the files that we do want included in the coverage report.
I would use dir to list all m-files in all subfolders of the folder and then take from that the files to exclude...
% get all m-code files under the folder
dirOut = dir(fullfile(folderPath, '**', '*.m'));
codeFilePaths = string({dirOut.folder}) + filesep + string({dirOut.name});
% remove files to exclude
codeFilePaths(ismember(codeFilePaths, filePathsToExclude)) = [];
% add the code coverage plugin
runner.addPlugin(CodeCoveragePlugin.forFile(codeFilePaths), ...
"Producing", codeCoverageFormat)
I'm using MATLAB R2019b, but I can confirm the above will also work in R2017b.
According to the documentation matlab.unittest.plugins.CodeCoveragePlugin.forFile was introduced in R2017b, so this won't work for older releases.