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.


Set the data type of an output port


DTypeId ssSetOutputPortDataType(SimStruct *S, int_T port, DTypeId id)



SimStruct representing an S-Function block.


Index of an output port.


ID of the data type accepted by port.


The data type ID specified by id. Returns -1 if id is DYNAMICALLY_TYPED.


Use this function in mdlInitializeSizes to set the data type of the output port specified by port. If the output port's data type is determined dynamically, for example, from the data type of a block parameter, set the data type to DYNAMICALLY_TYPED. In this case, the S-function must provide mdlSetOutputPortDataType and mdlSetDefaultPortDataTypes methods to enable the data type to be set correctly during signal propagation.

For a list of built-in data types, see ssGetInputPortDataType.

    Note   The data type of an output port is double (real_T) by default.


C, C++


Suppose that you want to create an S-function with two output ports, the first of which gets its data type from a block parameter and the second of which outputs signals of type int16_T. The following code sets up the data types.

ssSetOutputPortDataType(S, 0, DYNAMICALLY_TYPED)
ssSetOutputPortDataType(S, 1, SS_INT16)

See the S-function sfun_dtype_io.c used in sfcndemo_dtype_io and the S-function sdotproduct.c used in sfcndemo_sdotproduct for complete examples that use this function.

Introduced before R2006a

Was this topic helpful?