mdlSetDefaultPortDimensionInfo
Set the default dimensions of the signals accepted or emitted by a C MEX S-function's ports
Required
No
Languages
C, C++
Syntax
#定义MDL_SET_DEFAULT_PORT_DIMENSION_INFOvoid mdlSetDefaultPortDimensionInfo(SimStruct *S)
Arguments
-
S
-
SimStruct representing an S-Function block.
Description
The Simulink®engine calls this method during signal dimension propagation when a model does not supply enough information to determine the dimensionality of signals that can enter or leave the block represented byS
. This method should set the dimensions of any input and output ports that are dynamically sized to default values. This method is only valid for simulation, and must be enclosed in a#if defined(MATLAB_MEX_FILE)
statement.
If the S-function does not implement this method, the engine tries to find a set of dimensions that will satisfy the dimension propagation rules implemented usingmdlSetInputPortDimensionInfo
andmdlSetOutputPortDimensionInfo
. This process might not be able to produce a valid set of dimensions for S-functions with special dimension requirements.
The engine invokes an error if themdlSetDefaultPortDimensionInfo
method attempts to modify the dimensions of a port when the dimensions were previously specified bymdlSetInputPortDimensionInfo
ormdlSetOutputPortDimensionInfo
. If an S-function has multiple input or output ports,mdlSetDefaultPortDimensionInfo
should check if the dimensions of the port are still dynamic before attempting to set the dimensions. For example, themdlSetDefaultPortDimensionInfo
uses the following lines to check if the dimensions of the first output port are still unknown.
if (ssGetOutputPortWidth(S, 0) == DYNAMICALLY_SIZED) { ssSetOutputPortMatrixDimensions(S, 0, 1, 1 ); }
Example
Seesfun_matadd.c
for an example of how to use this function.