This example shows how to create an instrumented MEX function, run a test bench, then view logged results.
Define prototype input arguments.
Generate an instrumented MEX function. Use the -o option to specify the MEX function name. Use the -histogram option to compute histograms.
If you have a MATLAB® Coder™ license, you can also add the -coder option. For example,
buildInstrumentedMex testfft -coder -o testfft_instrumented -args {x,w}
Like the fiaccel function, the buildInstrumentedMex function generates a MEX function. To generate C code, use the MATLAB® Coder™ codegen function.
Run a test file to record instrumentation results.
Use the showInstrumenationResults function to open the report. To view the simulation minimum and maximum values and whole number status, pause over a variable in the report. The variable information also displays in the Variables tab of the report.
You can switch to the Data Type Visualizer tab to view a histogram of ranges for all the variables in the function. The histogram shows the data type ranges and logged ranges from simulation to help you quickly identify overflows. You can click on a histogram bin to see the associated variable information.
In this example, all of the logged values fall within their respective data type ranges. No overflows are detected.
Close the report, then use the clearInstrumentationResults function to clear the results log.
Run a different test bench, then view the new instrumentation results.
To view the histogram for a variable, click the histogram icon in the Variables tab.
Close the histogram display, then use the clearInstrumentationResults function to clear the results log.
Clear the MEX function.