MATLAB: How to obtain code coverage

code coverage

Hi i'm working with a MATLAB code which has 1 main and 7 functions, i need to check the code coveage of entire code with 5 test cases, where i need to verify how much code has been covered by applying all 5 cases as a whole. Please share your idea… Thanks in advance….

Best Answer

Hi!
Do you know the profiler? This is what you need. Look in the documentation on how to profile a script/function. This gives you many information about the execution. For your question: look at the resulting "ExecutedLines" array.
You can profile the function for each test case and get the aggregated "ExecutedLines" for all test cases. Compare that to the real code lines (non-blank and non-comment lines).