Fixed-Point Conversion

Convert floating-point code to fixed point, optimize fixed-point data types (requires Fixed-Point Designer™)

Classes

coder.FixptConfigFloating-point to fixed-point conversion configuration object

Functions

coderOpen MATLAB Coder app
codegenGenerate C/C++ code from MATLAB code
coder.configCreate MATLAB Coder code generation configuration objects
coder.approximationCreate function replacement configuration object

Examples and How To

Automated Conversion — App Workflow

Convert MATLAB Code to Fixed-Point C Code

Generate fixed-point C code from floating-point MATLAB® code.

Propose Fixed-Point Data Types Based on Simulation Ranges

Propose fixed-point data types based on simulation ranges using the MATLAB Coder™ app.

Propose Fixed-Point Data Types Based on Derived Ranges

Propose fixed-point data types based on static ranges using the MATLAB Coder app.

View and Modify Variable Information

View and modify variable information for fixed-point conversion.

Specify Type Proposal Options

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

Detect Overflows

Detect overflows using the app.

Replace the exp Function with a Lookup Table

Replace a function with a lookup table approximation in fixed-point code generated with the MATLAB Coder app.

Replace a Custom Function with a Lookup Table

Replace a custom function with a lookup table approximation function by using the MATLAB Coder app.

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.

Detect Dead and Constant-Folded Code

Learn how the app detects dead code or code that is constant folded during simulation of your test file.

Convert Fixed-Point Conversion Project to MATLAB Scripts

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

Automated Conversion — Programmatic Workflow

Convert MATLAB Code to Fixed-Point C Code

Generate fixed-point C code with codegen.

Propose Fixed-Point Data Types Based on Simulation Ranges

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

Propose Fixed-Point Data Types Based on Derived Ranges

Propose fixed-point data types based on static ranges using the codegen 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 codegen function.

Replace a Custom Function with a Lookup Table

Replace a custom function with a lookup table approximation function by using the codegen 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

Automated Fixed-Point Conversion

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

MATLAB Language Features Supported for Automated Fixed-Point Conversion

For automated fixed-point conversion, use supported MATLAB language features.

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.

Replacing Functions Using Lookup Table Approximations

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

Custom Plot Functions

Visualize numerical differences during fixed-point conversion.

Data Type Issues in Generated Code

Highlight potential data type issues in report.