Documentation

Convert a System to Single Precision

This example shows how to convert a system to single precision using the Single Precision Converter. This example converts all blocks in the model using double-precision data types to single-precision. To convert just a subsystem in a model to single precision, surround the subsystem under design with Data Type Conversion blocks before opening the Single Precision Converter.

  1. Open the model. At the command line, enter

    addpath(fullfile(docroot,'toolbox','fixpoint','examples'))
    ex_fuel_rate_calculation

    The model uses a combination of double-precision, Boolean, and built-in integer data types.

  2. Open the Single Precision Converter. From the Simulink® Analysis menu, select Data Type Design > Single Precision Converter.

  3. Under System Under Design, select the system or subsystem to convert to single precision. For this example, select the top-level model, ex_fuel_rate_calculation. Click Convert to Single.

    The converter first checks the system for compatibility with the conversion and changes any model settings that are incompatible. The standard math library of the model is now set to C99 (ISO), and the model now uses a fixed-step solver.

    The converter then converts the system and lists all converted data types. The converter changes only double-precision data types. It does not convert Boolean, fixed-point, or built-in integer types to single precision. In the final stage of the conversion, the Converter verifies that the conversion was successful by updating the model.

  4. Return to the model and update the diagram. The model no longer contains double-precision data types.

Related Topics

Was this topic helpful?