coder.SingleConfig - Double-precision to single-precision conversion configuration object - MATLAB (original) (raw)

Main Content

Namespace: coder

Double-precision to single-precision conversion configuration object

Description

A coder.SingleConfig object contains the configuration parameters that the MATLAB® Coder™ codegen function requires to convert double-precision code to single-precision MATLAB code. To pass this object to the codegen function, use the -double2single 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. Comparison 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, setLogIOForComparisonPlotting to true. This option takes precedence overPlotWithSimulationDataInspector.

The plot function must accept three inputs:

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

addFunctionReplacement (Fixed-Point Designer) Replace double-precision function with single-precision function during single-precision conversion

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 ismyfunction_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 codegen. Use the-double2single option to specify the coder.SingleConfig that you want to use. In this example, the MATLAB function name ismyfunction.

codegen -double2single scfg myfunction

Alternatives

You can convert double-precision MATLAB code to single-precision C/C++ code by using the 'singleC' option of the codegen function.

You can convert double-precision MATLAB code to single-precision code using the MATLAB Coder app. Open the app using one of these methods:

Version History

Introduced in R2015b