Main Content

coder.SingleConfig Class

Namespace: coder

Double-precision to single-precision conversion configuration object

Description

A coder.SingleConfig object contains the configuration parameters that the convertToSingle function requires to convert double-precision MATLAB® code to single-precision MATLAB code. To pass this object to the convertToSingle function, use the -config option.

Creation

scfg = coder.config('single') creates a coder.SingleConfig object for double-precision to single-precision conversion.

Properties

expand all

Suffix that the single-conversion process uses for generated single-precision filenames, specified as a character vector.

Option to enable simulation data logging for comparison plotting, specified as true or false. Comparion plotting plots the differences introduced by single-precision conversion.

Name of function to use for comparison plots, specified as a character vector

To enable comparison plotting, set LogIOForComparisonPlotting to true. This option takes precedence over PlotWithSimulationDataInspector.

The plot function must accept three inputs:

  • A structure that holds the name of the variable and the function that uses it.

  • A cell array to hold the logged floating-point values for the variable.

  • A cell array to hold the logged values for the variable after fixed-point conversion.

Option to use Simulation Data Inspector for comparison plots, specified as true or false.

LogIOForComparisonPlotting must be set to true to enable comparison plotting. The PlotFunction option takes precedence over PlotWithSimulationDataInspector.

Names of test files, specified as a character vector or cell array of character vectors. Specify at least one test file.

If you do not explicitly specify input parameter data types, the conversion uses the first file to infer these data types.

Option to enable numerics testing to verify the generated single-precision code, specified as true or false. The test file runs the single-precision code.

Methods

expand all

Examples

collapse all

Create a coder.SingleConfig object.

scfg = coder.config('single'); 

Set the properties of the double-precision to single-precision conversion object. Specify the test file. In this example, the name of the test file is myfunction_test. The conversion process uses the test file to infer input data types and collect simulation range data. Enable numerics testing and generation of comparison plots.

scfg.TestBenchName = 'myfunction_test';
scfg.TestNumerics = true;
scfg.LogIOForComparisonPlotting = true;

Run convertToSingle. Use the -config option to specify the coder.SingleConfig object that you want to use. In this example, the MATLAB function name is myfunction.

convertToSingle -config scfg myfunction 

Version History

Introduced in R2015b