Automated Conversion

Automated fixed-point conversion, Fixed-Point Converter app, command-line

Apps

Fixed-Point ConverterConvert MATLAB code to fixed point

Functions

fiaccelAccelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code
coder.configCreate configuration object for fixed-point or single-precision conversion
coder.mexconfigCode acceleration configuration object
coder.approximationCreate function replacement configuration object
coder.allowpcodeControl code generation from protected MATLAB files
coder.constFold expressions into constants in generated code
coder.extrinsicDeclare extrinsic functions
coder.inlineControl inlining in generated code
coder.loadLoad compile-time constants from MAT-file or ASCII file into caller workspace
coder.newtypeCreate a coder.Type object
coder.nullcopyDeclare uninitialized variables in code generation
coder.resizeResize coder.Type object
coder.targetDetermine if code generation target is specified target
coder.typeofCreate coder.Type object to represent the type of an entry-point function input
coder.unrollUnroll for-loop by making a copy of the loop body for each loop iteration
coder.varsizeDeclare variable-size data

Classes

coder.MexConfigCode acceleration configuration object for use with fiaccel
coder.FixptConfigFloating-point to fixed-point conversion configuration object
coder.ArrayTypeRepresent set of MATLAB arrays
coder.ConstantRepresent set containing one MATLAB value
coder.EnumTypeRepresent set of MATLAB enumerations
coder.FiTypeRepresent set of MATLAB fixed-point arrays
coder.PrimitiveTypeRepresent set of logical, numeric, or char arrays
coder.StructTypeRepresent set of MATLAB structure arrays
coder.TypeRepresent set of MATLAB values

Examples and How To

Automated Fixed-Point Conversion Workflow

Propose Data Types Based on Simulation Ranges

Propose fixed-point data types based on simulation ranges using the Fixed-Point Converter app.

Propose Data Types Based on Derived Ranges

Propose fixed-point data types based on static ranges using the Fixed-Point Converter app.

Convert Fixed-Point Conversion Project to MATLAB Scripts

Use project settings for fixed-point conversion at the command line.

Fixed-Point Type Proposal

Specify Type Proposal Options

Specify options used when proposing types for automated fixed-point conversion.

View and Modify Variable Information

View and modify variable information for fixed-point conversion.

Detect Dead and Constant-Folded Code

During the simulation of your test file, the app detects dead code or code that is constant folded.

Conversion to Fixed Point

Generated Fixed-Point Code

Avoid issues with generated fixed-point code.

Replace the exp Function with a Lookup Table

Replace a function with a lookup table approximation in fixed-point code generated with the Fixed-Point Converter app.

Replace a Custom Function with a Lookup Table

Replace a custom function with a lookup table approximation function by using the Fixed-Point Converter app.

Result Verification

Visualize Differences Between Floating-Point and Fixed-Point Results

Use a custom plot function to compare the behavior of the generated fixed-point code against the behavior of the original floating-point MATLAB code.

Enable Plotting Using the Simulation Data Inspector

Inspect and compare floating-point and fixed-point logged input and output data.

Detect Overflows

Detect overflows using the app.

Language Feature Support

Convert Code Containing Global Variables to Fixed-Point

Convert MATLAB code using global variables to fixed-point using the app.

Convert Code Containing Structures to Fixed Point

Convert a MATLAB® algorithm containing structures to fixed point using the Fixed-Point Converter app.

Generate Fixed-Point MATLAB Code for Multiple Entry-Point Functions

Generate fixed-point code for multiple entry-point functions using the Fixed-Point Converter app.

Convert dsp.FIRFilter Object to Fixed-Point Using the Fixed-Point Converter App

This example converts a dsp.FIRFilter System object™, which filters a high-frequency sinusoid signal, to fixed-point using the Fixed-Point Converter app.

Programmatic Workflow

Propose Data Types Based on Simulation Ranges

Propose fixed-point data types based on simulation ranges using the fiaccel function.

Propose Data Types Based on Derived Ranges

Propose fixed-point data types based on static ranges using the fiaccel function.

Detect Overflows

Detect overflows at the command line.

Replace the exp Function with a Lookup Table

Replace a function with a lookup table approximation in fixed-point code generated with the fiaccel function.

Replace a Custom Function with a Lookup Table

Replace a custom function with a lookup table approximation function by using the fiaccel function.

Enable Plotting Using the Simulation Data Inspector

Inspect and compare floating-point and fixed-point logged input and output data.

Visualize Differences Between Floating-Point and Fixed-Point Results

Use a custom plot function to compare the behavior of the generated fixed-point code against the behavior of the original floating-point MATLAB code.

Concepts

Fixed-Point Conversion Workflows

Learn more about the different fixed-point conversion methods. The conversion method you use depends on your end goal and your level of fixed-point expertise.

Automated Fixed-Point Conversion

Using the Fixed-Point Converter app for automated fixed-point conversion.

MATLAB Language Features Supported for Automated Fixed-Point Conversion

Summary of language features that are and are not supported for automated fixed-point conversion.

Automated Fixed-Point Conversion Best Practices

Generate fixed-point code according to best practices.

Generated Fixed-Point Code

Avoid issues with generated fixed-point code.

Fixed-Point Code for MATLAB Classes

Use supported constructs and coding style best practices for fixed-point conversion of MATLAB classes.

Generate Fixed-Point MATLAB Code for Multiple Entry-Point Functions

Generate fixed-point code for multiple entry-point functions using the Fixed-Point Converter app.

Convert Code Containing Global Data to Fixed Point

Convert MATLAB code using global variables to fixed-point programmatically.

Replacing Functions Using Lookup Table Approximations

Generate lookup table approximations to replace custom functions or functions that are not supported for fixed point.

Inspecting Data Using the Simulation Data Inspector

The Simulation Data Inspector allows you to view data logged during the fixed-point conversion process.

Custom Plot Functions

Visualize numerical differences during fixed-point conversion.

Data Type Issues in Generated Code

Highlight potential data type issues in report.

System Objects Supported by Fixed-Point Converter App

You can use the Fixed-Point Converter app to automatically propose and apply data types for commonly used system objects.

Troubleshooting

Debug Numerical Issues in Fixed-Point Conversion Using Variable Logging

Techniques for debugging your fixed-point code when you need more than out of the box conversion.

Why Does the Fixed-Point Converter App Not Propose Data Types for System Objects?

How to troubleshoot missing data type proposals for System objects

Slow Operations in the Fixed-Point Converter App

By default, the MATLAB Coder™Fixed-Point Converter app screens your entry-point functions for code generation readiness.