Set the Output Port Data Type
You may want to set the data type of various ports, run-time parameters, or DWorks in your S-function.
For example, suppose you want to set the output port data type of your S-function. To do this,
Register a data type by using one of the functions listed in the table Data Type Registration Functions. A data type ID is returned.
Alternately, you can use one of the predefined data type IDs of the Simulink® built-in data types.
Use
ssSetOutputPortDataType
with the data type ID from Step 1 to set the output port to the desired data type.
In the example below from lines 354 - 370 of sfun_user_fxp_const.c
,
ssRegisterDataTypeFxpBinaryPoint
is used to register the data
type. ssSetOutputPortDataType
then sets the output data type either
to the given data type ID, or to be dynamically typed:
/* Register data type */ if ( notSizesOnlyCall ) { DTypeId DataTypeId = ssRegisterDataTypeFxpBinaryPoint( S, V_ISSIGNED, V_WORDLENGTH, V_FRACTIONLENGTH, 1 /* true means obey data type override setting for this subsystem */ ); ssSetOutputPortDataType( S, 0, DataTypeId ); } else { ssSetOutputPortDataType( S, 0, DYNAMICALLY_TYPED ); }