| Contents | Index |
| On this page… |
|---|
The API for user-written fixed-point S-functions provides support for a variety of Simulink and Simulink Fixed Point 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 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 Simulink Fixed Point software license to be checked out.
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, refer to Fixed-Point Tool and the fxptdlg reference page in the Simulink documentation.
![]() | Writing Fixed-Point S-Functions | Structure of the S-Function | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |