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
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, 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.
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.
Methods
Public Methods
addFunctionReplacement | Replace double-precision function with single-precision function during single-precision conversion |
Examples
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 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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)