Main Content

Fixed-Point Converter

Convert MATLAB code to fixed point


The Fixed-Point Converter app converts floating-point MATLAB® code to fixed-point MATLAB code.

Using the app, you can:

  • Propose data types based on simulation range data, static range data, or both.

  • Propose fraction lengths based on default word lengths or propose word lengths based on default fraction lengths.

  • Optimize whole numbers.

  • Specify safety margins for simulation min/max data.

  • View a histogram of bits used by each variable.

  • Specify replacement functions or generate approximate functions for functions in the original MATLAB algorithm that do not support fixed point.

  • Test the numerical behavior of the fixed-point code. You can then compare its behavior against the floating-point version of your algorithm using either the Simulation Data Inspector or your own custom plotting functions.

If your end goal is to generate fixed-point C code, use the MATLAB Coder™ app instead. See Convert MATLAB Code to Fixed-Point C Code (MATLAB Coder).

If your end goal is to generate HDL code, use the HDL Coder™ workflow advisor instead. See Floating-Point to Fixed-Point Conversion (HDL Coder).

Fixed-Point Converter app

Open the Fixed-Point Converter App

  • MATLAB Toolstrip: On the Apps tab, under Code Generation, click the app icon.

  • MATLAB command prompt: Enter fixedPointConverter.

  • To open an existing Fixed-Point Converter app project, either double-click the .prj file or open the app and browse to the project file.

    Creating a project or opening an existing project causes any other Fixed-Point Converter or MATLAB Coder projects to close.

  • A MATLAB Coder project opens in the MATLAB Coder app. To convert the project to a Fixed-Point Converter app project, in the MATLAB Coder app:

    1. Click and select Reopen project as.

    2. Select Fixed-Point Converter.

Programmatic Use

expand all

fixedPointConverter opens the Fixed-Point Converter app.

fixedPointConverter -tocode projectname converts the existing project named projectname.prj to the equivalent script of MATLAB commands. It writes the script to the Command Window.

fixedPointConverter -tocode projectname -script scriptname converts the existing project named projectname.prj to the equivalent script of MATLAB commands. The script is named scriptname.m.

  • If scriptname already exists, fixedPointConverter overwrites it.

  • The script contains the MATLAB commands to:

    • Create a floating-point to fixed-point conversion configuration object that has the same fixed-point conversion settings as the project.

    • Run the fiaccel command to convert the floating-point MATLAB function to a fixed-point MATLAB function.

Before converting the project to a script, you must complete the Test step of the fixed-point conversion process.

Version History

Introduced in R2014b