Main Content

ssSetInputPortDimensionInfo

Specify information about the dimensionality of an input port

Syntax

int_T ssSetInputPortDimensionInfo(SimStruct *S, int_T port, DimsInfo_T *dimsInfo)

Arguments

S

SimStruct representing an S-Function block.

port

Index of an input port.

dimsInfo

Structure of typeDimsInfo_Tthat specifies the dimensionality of the signals accepted byport.

The structure is defined as

typedef struct DimsInfo_tag{ int width; /* number of elements */ int numDims /* Number of dimensions */ int *dims; /* Dimensions. */ [snip] }DimsInfo_T;

where

  • numDimsspecifies the number of dimensions of the signal, e.g., 1 for a 1-D (vector) signal or 2 for a 2-D (matrix) signal, orDYNAMICALLY_SIZEDif the number of dimensions is determined dynamically.

  • dimsis an integer array that specifies the size of each dimension, e.g.,[2 3]for a 2-by-3 matrix signal, orDYNAMICALLY_SIZED for each dimension that is determined dynamically, e.g., [2 DYNAMICALLY_SIZED].

  • widthequals the total number of elements in the signal, e.g., 12 for a 3-by-4 matrix signal or 8 for an 8-element vector signal, orDYNAMICALLY_SIZEDif the total number of elements is determined dynamically.

    Note

    Use the macro,DECL_AND_INIT_DIMSINFO, to declare and initialize an instance of this structure.

Returns

1if successful; otherwise,0.

Description

Specifies the dimension information forport. Use this function inmdlInitializeSizesto initialize the input port dimension information. If you want the port to inherit its dimensions from the port to which it is connected, specifyDYNAMIC_DIMENSIONas thedimsInfoforport. In this case, the S-function must providemdlSetInputPortDimensionInfoandmdlSetDefaultPortDimensionInfomethods to enable the signal dimensions to be set correctly during signal propagation.

语言

C, C++

Example

The following example specifies that input port 0 accepts 2-by-2 matrix signals.

{ DECL_AND_INIT_DIMSINFO(di); int_T dims[2]; di.numDims = 2; dims[0] = 2; dims[1] = 2; di.dims = dims; di.width = 4; ssSetInputPortDimensionInfo(S, 0, &di); }

See the S-functionsfun_matadd.cused insfcndemo_mataddand the S-functionsdotproduct.cused insfcndemo_sdotproductfor complete examples that use this function.

Introduced before R2006a