Main Content


Results logged by instrumented, compiled C code function


showInstrumentationResults('mex_fcn') opens the Instrumentation Report Viewer, showing results from calling the instrumented MEX function mex_fcn.

Hovering over variables and expressions in the report displays the logged information. The logged information includes minimum and maximum values, proposed fraction or word lengths, percent of current range, and whether the value is always a whole number, depending on which options you specify. If you specify to include them in the buildInstrumentedMex function, histograms are also included. The same information is displayed in a summary table in the Variables tab.

When you call showInstrumentationResults, a file named instrumentation/mex_fcn/html/printable.html is created. mex_fcn is the name of the corresponding instrumented MEX function. Selecting this file opens a web-based version of the Instrumentation Report Viewer. To open this file from within MATLAB®, right-click on the file and select Open Outside MATLAB.

The showInstrumentationResults function returns an error if the instrumented mex_fcn has not yet been called.


The logged results from the showInstrumentationResults function are an accumulation of all previous calls to the instrumented MEX function. To clear the log, see clearInstrumentationResults.

showInstrumentationResults('mex_fcn','-options') specifies options for the instrumentation results section of the Instrumentation Report Viewer.


showInstrumentationResults mex_fcn and showInstrumentationResults mex_fcn -options are alternative syntaxes for opening the Instrumentation Report Viewer.


collapse all

This example shows how to create an instrumented MEX function, run a test bench, then view logged results.

Define prototype input arguments.

n = 128;
x = complex(zeros(n,1));
w = fi_radix2twiddles(n);

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. In this case,

buildInstrumentedMex testfft -o testfft_instrumented -args {x,coder.Constant(w)} -histogram

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 showInstrumentedMex function to open the report. To view the simulation minimum and maximum values and whole number status, pause over a variable in the report. You can also see proposed data types for double precision numbers in the table.

for i=1:20
   y = testfft_instrumented(randn(size(x)),w);

showInstrumentationResults testfft_instrumented


Close the histogram display, then use the clearInstrumentationResults function to clear the results log.

clearInstrumentationResults testfft_instrumented

Run a different test bench, then view the new instrumentation results.

for i=1:20
   y = testfft_instrumented(cast(rand(size(x))-0.5,'like',x),w);

showInstrumentationResults testfft_instrumented


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.

clearInstrumentationResults testfft_instrumented

Clear the MEX function.

clear testfft_instrumented

Input Arguments

collapse all

Instrumented MEX function created using buildInstrumentedMex.

Instrumentation results options, specified as:

-defaultDT T

Default data type to propose for double or single data type inputs, where T is either a numerictype object or one of the following: 'remainFloat' (default), 'double', 'single', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', or 'uint64'.

If you specify an int or uint, the signedness and word length are that int or uint value and a fraction length is proposed.

The default is remainFloat, which does not propose any data types.


Do not display MATLAB code in the printable report. Display only the tables of logged variables. This option only has effect in combination with the -printable option.


Optimize the word length of variables whose simulation min/max logs indicate that they are always whole numbers.

-percentSafetyMargin N

Safety margin for simulation min/max, where N is a percent value.


Create and open a printable HTML report. The report opens in the system browser.


Propose fraction lengths for specified word lengths.


Propose word lengths for specified fraction lengths.

Version History

Introduced in R2011b

expand all