Data Types and Scaling

Fixed-point and floating-point number representation, scaling, quantization, range, precision

In models, data types determine the interactions between signals and block parameters. Numeric data types determine how a computer stores signals and parameters in memory and how a computer performs math operations.

To simulate the mathematical behavior of computer hardware, or to generate efficient code from a model, you can control the numeric data types of signals and parameters.

Topics

Fixed-Point Numbers in Simulink

Describes how fixed-point numbers are represented in Simulink®.

Floating-Point Numbers

Discusses the representation and manipulation of floating-point numbers

Supported Data Types

Data types supported for simulation and code generation

Scaling

The dynamic range of fixed-point numbers is much less than floating-point numbers with equivalent word sizes. To avoid overflow conditions and minimize quantization errors, fixed-point numbers must be scaled.

Quantization

The quantization of a real-world value is represented by a weighted sum of bits.

Range and Precision

The range of a number gives the limits of the representation, while the precision gives the distance between successive numbers in the representation. The range and precision of a fixed-point number depend on the length of the word and the scaling.

Scaled Doubles

Scaled doubles are a hybrid between floating-point and fixed-point numbers. The Fixed-Point Designer™ software stores them as doubles with the scaling, sign, and word length information retained.

Cast from Doubles to Fixed Point

Provides an example based on the fxpdemo_dbl2fix model, which highlights many of the key features of the Fixed-Point Designer software

Use Scaled Doubles to Avoid Precision Loss

How to avoid precision loss by overriding the data types in your model with scaled doubles.

Display Port Data Types

The port display for fixed-point signals consists of three parts: the data type, the number of bits, and the scaling.