Main Content

mdlSetDefaultPortDataTypes

Set the data types of ports whose data types cannot be determined from block connectivity

Required

No

Languages

C, C++

Syntax

#define MDL_SET_DEFAULT_PORT_DATA_TYPES
void mdlSetDefaultPortDataTypes(SimStruct *S)

Arguments

S

SimStruct representing an S-Function block.

Description

The Simulink® engine invokes this method if the block has ports whose data types cannot be determined from block connectivity. (This usually happens when the block is unconnected or is part of a feedback loop.) This method must set the data types of all ports whose data types are not set. This method is only valid for simulation, and must be enclosed in a #if defined(MATLAB_MEX_FILE) statement.

If the block does not implement this method and the engine cannot determine the data types of any of its ports, the engine sets the data types of all the ports to double. If the block does not implement this method and the engine cannot determine the data types of some, but not all, of its ports, the engine sets the unknown ports to the data type of the port whose data type has the largest size.

The engine invokes an error if the mdlSetDefaultPortDataType method attempts to modify the data type of a port when the data type was previously specified by mdlSetInputPortDataType or mdlSetOutputPortDataType. If an S-function has multiple input or output ports, mdlSetDefaultPortDataType should check if the data type of a port is still dynamic before attempting to set the type. For example, the mdlSetDefaultPortDataType uses the following lines to check if the data type of the second input port is still unknown.

     if (ssGetInputPortDataType(S, 1) == DYNAMICALLY_TYPED) {
        ssSetInputPortDataType(S, 1, SS_UINT8 );
     }

Version History

Introduced before R2006a