Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

mdlSetInputPortDimensionInfo - Set the dimensions of the signals accepted by an input port

Required

No

C Syntax

#define MDL_SET_INPUT_PORT_DIMENSION_INFO
void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, 
  const DimsInfo_T *dimsInfo)

C Arguments

S

SimStruct representing an S-Function block.

port

Index of a port.

dimsInfo

Structure that specifies the signal dimensions supported by the port.

See ssSetInputPortDimensionInfo for a description of this structure.

M Syntax

SetInputPortDimensions(s, port, dimsInfo)

M Arguments

s

Instance of Simulink.MSFcnRunTimeBlock class representing the Level-2 M-File S-Function block.

port

Integer value specifying index of port to be set.

dimsInfo

Array that specifies the signal dimensions supported by the port, e.g., [5] for a 5-element vector signal or [3 3] for a 3-by-3 matrix signal.

Description

The Simulink engine calls this method during dimension propagation with candidate dimensions dimsInfo for port. In C MEX S-functions, if the proposed dimensions are acceptable, the method sets the actual port dimensions, using ssSetInputPortDimensionInfo. If they are unacceptable, the method generates an error via ssSetErrorStatus.

A Level-2 M-file S-function sets the input port dimensions using the line

s.InputPort(port).Dimensions = dimsInfo;

This method is only valid for simulation. A C MEX S-function must enclose the method in a #if defined(MATLAB_MEX_FILE) statement.

By default, the engine calls this method only if it can fully determine the dimensionality of port from the port to which it is connected. For C MEX S-functions, if the engine cannot completely determine the dimensionality from port connectivity, it invokes mdlSetDefaultPortDimensionInfo. If an S-function can fully determine the port dimensionality from partial information, set the option SS_OPTION_ALLOW_PARTIAL_DIMENSIONS_CALL in mdlInitializeSizes, using ssSetOptions. If this option is set, the engine invokes mdlSetInputPortDimensionInfo even if it can only partially determine the dimensionality of the input port from connectivity.

The engine calls this method until all input ports with inherited dimensions have their dimensions specified.

C Example

See matlabroot/toolbox/simulink/simdemos/simfeatures/src/sfun_matadd.c for an example of how to use this function.

Languages

C, C++, M

See Also

ssSetErrorStatus, mdlSetOutputPortDimensionInfo

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS