Inherit Custom Data Types
Level-2 MATLAB® S-functions do not support defining custom data types within the
S-function. However, input and output ports can inherit their data types from a
Simulink.NumericType
or Simulink.AliasType
object. For example, the S-function in the following model inherits its input data type
from the Constant block:
The Constant block's Output data type field contains the value
MyDouble
, which is a Simulink.AliasType
defined in the MATLAB workspace with the following line of code:
MyDouble = Simulink.AliasType('double');
The input and output ports of the Level-2 MATLAB S-function msfcn_inheritdt.m
inherit their data types.
When the Simulink® engine performs data type propagation, it assigns the data type
MyDouble
to these ports.
You can define a fixed-point data type within a Level-2 MATLAB S-function, using one of the following three methods:
RegisterDataTypeFxpBinaryPoint
registers a fixed-point data type with binary point-only scalingRegisterDataTypeFxpFSlopeFixExpBias
registers a fixed-point data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and biasRegisterDataTypeFxpSlopeBias
registers a data type with [Slope Bias] scaling
Note
If the registered data type is not one of the Simulink built-in data types, you must have a Fixed-Point Designer™ license.
If you have Fixed-Point Designer, inspect the example models and S-functions provided with the software for examples using the macros for defining fixed-point data types.
See Also
Level-2 MATLAB S-Function | S-Function Builder | S-Function | MATLAB Function