This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Data Type Support

Supported Data Types

The API for user-written fixed-point S-functions provides support for a variety of Simulink® and Fixed-Point Designer™ data types, including

  • Built-in Simulink data types

    • single

    • double

    • uint8

    • int8

    • uint16

    • int16

    • uint32

    • int32

  • Fixed-point Simulink data types, such as

    • sfix16_En15

    • ufix32_En16

    • ufix128

    • sfix37_S3_B5

  • Data types resulting from a data type override with Scaled double, such as

    • flts16

    • flts16_En15

    • fltu32_S3_B5

For more information, see Fixed-Point Data Type and Scaling Notation.

The Treatment of Integers

The API treats integers as fixed-point numbers with trivial scaling. In [Slope Bias] representation, fixed-point numbers are represented as

real-world value = (slope  × integer) + bias.

In the trivial case, slope  =  1 and bias  =  0.

In terms of binary-point-only scaling, the binary point is to the right of the least significant bit for trivial scaling, meaning that the fraction length is zero:

real-world value = integer × 2-fraction length = integer ×  20.

In either case, trivial scaling means that the real-world value is equal to the stored integer value:

real-world value = integer.

All integers, including Simulink built-in integers such as uint8, are treated as fixed-point numbers with trivial scaling by this API. However, Simulink built-in integers are different in that their use does not cause a Fixed-Point Designer software license to be checked out.

Data Type Override

The Fixed-Point Tool enables you to perform various data type overrides on fixed-point signals in your simulations. This API can handle signals whose data types have been overridden in this way:

  • A signal that has been overridden with Single is treated as a Simulink built-in single.

  • A signal that has been overridden with Double is treated as a Simulink built-in double.

  • A signal that has been overridden with Scaled double is treated as being of data type ScaledDouble.

ScaledDouble signals are a hybrid between floating-point and fixed-point signals, in that they are stored as doubles with the scaling, sign, and word length information retained. The value is stored as a floating-point double, but as with a fixed-point number, the distinction between the stored integer value and the real-world value remains. The scaling information is applied to the stored integer double to obtain the real-world value. By storing the value in a double, overflow and precision issues are almost always eliminated. Refer to any individual API function reference page at the end of this appendix to learn how that function treats ScaledDouble signals.

For more information about the Fixed-Point Tool and data type override, see Fixed-Point Tool and the fxptdlg reference page.

Was this topic helpful?