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 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

OutputFileNameSuffix — Suffix for single-precision filenames

'_single' (default) | character vector

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

LogIOForComparisonPlotting — Option to enable simulation data logging for comparison plotting

false (default) | true

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

PlotFunction — Name of function for comparison plots

'' (default) | character vector

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:

PlotWithSimulationDataInspector — Option to use of Simulation Data Inspector for comparison plots

false (default) | true

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.

TestBenchName — Names of test file

'' (default) | character vector | cell array of character vectors

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.

TestNumerics — Option to enable numerics testing

false (default) | true

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.

Examples

collapse all

Generate Single-Precision MATLAB Code

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

convertToSingle -config scfg myfunction

Version History

Introduced in R2015b