Configure C/C++ S-Function Features
C/C++ S-functions allow you to configure extended block functionality through various callback and SimStruct methods.
Create and configure input/output ports.
Specify block-based and port-based sample times.
Pass dialog parameters to S-functions.
Model zero crossings and allocate memory for S-functions.
Configure code generation settings for S-functions.
S-Function Callback Methods
Input and Output
Initialize, Output, Terminate
mdlInitializeSizes | Specify the number of inputs, outputs, states, parameters, and other characteristics of the C MEX S-function |
mdlInitializeSampleTimes | Specify the sample rates at which this C MEX S-function operates |
mdlOutputs | Compute the signals that this block emits |
mdlUpdate | Update a block's states |
mdlTerminate | Perform any actions required at termination of the simulation |
Signal Specification
mdlSetDefaultPortComplexSignals | Set the numeric types (real, complex, or inherited) of ports whose numeric types cannot be determined from block connectivity |
mdlSetDefaultPortDataTypes | Set the data types of ports whose data types cannot be determined from block connectivity |
mdlSetDefaultPortDimensionInfo | Set the default dimensions of the signals accepted or emitted by a C MEX S-function's ports |
mdlSetInputPortComplexSignal | Set the numeric types (real, complex, or inherited) of the signals accepted by an input port |
mdlSetInputPortDataType | Set the data types of the signals accepted by an input port |
mdlSetInputPortSampleTime | Set the sample time of an input port that inherits its sample time from the port to which it is connected |
mdlSetOutputPortComplexSignal | Set the numeric types (real, complex, or inherited) of the signals accepted by an output port |
mdlSetOutputPortDataType | Set the data type of the signals emitted by an output port |
mdlSetOutputPortSampleTime | Set the sample time of an output port that inherits its sample time from the port to which it is connected |
Signal Dimensions
mdlSetInputPortDimensionInfo | Set the dimensions of the signals accepted by an input port |
mdlSetInputPortDimensionsModeFcn | Propagate the dimensions mode |
mdlSetInputPortWidth | Set the width of an input port that accepts 1-D (vector) signals |
mdlSetOutputPortDimensionInfo | Set the dimensions of the signals accepted by an output port |
mdlSetOutputPortWidth | Set the width of an output port that outputs 1-D (vector) signals |
Signal Access
mdlSetWorkWidths | Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function |
Sample Time
mdlSetInputPortSampleTime | Set the sample time of an input port that inherits its sample time from the port to which it is connected |
mdlSetOutputPortSampleTime | Set the sample time of an output port that inherits its sample time from the port to which it is connected |
Run-Time Parameters
mdlSetWorkWidths | Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function |
mdlCheckParameters | Check the validity of a C MEX S-function's parameters |
mdlProcessParameters | Process the C MEX S-function's parameters |
Model Reference
mdlStart | Initialize the state vectors of this C MEX S-function |
mdlProcessParameters | Process the C MEX S-function's parameters |
mdlSetWorkWidths | Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function |
Interactions with Simulink Engine
Simulation Information
mdlGetOperatingPoint | Return operating point for C MEX S-function as MATLAB data structure |
mdlSetOperatingPoint | Restore operating point of C MEX S-function |
Error Handling
mdlStart | Initialize the state vectors of this C MEX S-function |
mdlTerminate | Perform any actions required at termination of the simulation |
State and Work Vector
mdlSetWorkWidths | Specify the sizes of the work vectors and create the run-time parameters required by this C MEX S-function |
mdlZeroCrossings | Update zero-crossing vector |
mdlInitializeConditions | Initialize the state vectors of this C MEX S-function |
SimStruct Functions
Input and Output
Signal Specification
ssSetNumInputPorts | Specify the number of input ports that a block has |
ssSetInputPortComplexSignal | Set the numeric type (real or complex) of an input port |
ssSetInputPortDataType | Set the data type of an input port |
ssSetInputPortDirectFeedThrough | Specify the direct feedthrough status of a block's ports |
ssSetInputPortOffsetTime | Specify the offset time of an input port |
ssSetInputPortRequiredContiguous | Specify that the signal elements entering a port must be contiguous |
ssSetInputPortSampleTime | Specify the sample time of an input port |
ssRegisterUnitFromExpr | Register unit from unit expression |
ssSetInputPortUnit | Specify unit of input port |
ssSetNumOutputPorts | Specify the number of output ports that a block has |
ssSetOutputPortComplexSignal | Set the numeric type (real or complex) of an output port |
ssSetOutputPortDataType | Set the data type of an output port |
ssSetOutputPortOffsetTime | Specify the offset time of an output port |
ssSetOutputPortSampleTime | Specify the sample time of an output port |
ssSetOutputPortUnit | Specify unit of output port |
ssGetInputPortComplexSignal | Determine whether an input port accepts complex signals. |
ssGetInputPortDataType | Get the data type of an input port |
ssGetInputPortDirectFeedThrough | Determine whether a port has direct feedthrough |
ssGetInputPortFrameData | Determine whether a port accepts signal frames |
ssGetInputPortOffsetTime | Get the offset time of an input port |
ssGetInputPortRequiredContiguous | Determine whether the signal elements entering a port must be contiguous |
ssGetInputPortSampleTime | Get the sample time of an input port |
ssGetInputPortSampleTimeIndex | Get the sample time index of an input port |
ssGetInputPortUnit | Get unit of input port |
ssGetOutputPortComplexSignal | Get the numeric type (complex or real) of an output port |
ssGetOutputPortDataType | Get the data type of an output port |
ssGetOutputPortFrameData | Determine whether a port outputs signal frames |
ssGetOutputPortOffsetTime | Get the offset time of an output port |
ssGetOutputPortSampleTime | Get the sample time of an output port |
ssGetOutputPortUnit | Get unit of output port |
ssAllowSignalsWithMoreThan2D | Enable S-function to work with multidimensional signals |
ssSetOneBasedIndexInputPort | Specify that an input port expects one-based indices |
ssSetOneBasedIndexOutputPort | Specify that an output port emits one-based indices. |
ssSetZeroBasedIndexInputPort | Specify that an input port expects zero-based indices |
ssSetZeroBasedIndexOutputPort | Specify that an output port emits zero-based indices. |
Signal Access
ssGetNumInputPorts | Get the number of input ports that a block has |
ssGetNumOutputPorts | Get the number of output ports that a block has |
ssGetInputPortBufferDstPort | Determine the output port that is sharing this input port's buffer |
ssGetInputPortConnected | Determine whether a port is connected to a nonvirtual block |
ssGetInputPortOptimOpts | Get the reusability setting of the memory allocated to the input port of an S-function |
ssGetInputPortOverWritable | Determine whether an input port can be overwritten |
ssGetInputPortRealSignal | Get the address of a real, contiguous signal entering an input port |
ssGetInputPortRealSignalPtrs | Get
pointers to signals of type double connected to an input
port |
ssGetInputPortSignal | Get the address of a contiguous signal entering an input port |
ssGetInputPortSignalPtrs | Get pointers to an input port's signal elements |
ssGetOutputPortConnected | Determine whether an output port is connected to a nonvirtual block |
ssGetOutputPortBeingMerged | Determine whether the output of this block is connected to a Merge block |
ssGetOutputPortOptimOpts | Get the reusability setting of the memory allocated to the output port of an S-function |
ssGetOutputPortRealSignal | Get
a pointer to an output signal of type double
(real_T ) |
ssGetOutputPortSignal | Get the vector of signal elements emitted by an output port |
ssSetInputPortOptimOpts | Specify reusability of the memory allocated to the input port of an S-function |
ssSetInputPortOverWritable | Specify whether one of an S-function's input ports can be overwritten by one of its output ports |
ssSetOutputPortOptimOpts | Specify reusability of the memory allocated to the output port of an S-function |
ssSetOutputPortOverwritesInputPort | Specify whether an output port can share its memory buffer with an input port |
ssSetInputPortAcceptExprInRTW | Specify whether a block input accepts a nonconstant expression |
ssGetInputPortAcceptExprInRTW | Determine whether a block input accepts a nonconstant expression |
ssSetOutputPortOutputExprInRTW | Specify whether a block output generates a nonconstant expression |
ssGetOutputPortOutputExprInRTW | Determine whether a block output generates a nonconstant expression |
Signal Dimensions
ssSetInputPortDimensionInfo | Specify information about the dimensionality of an input port |
ssSetInputPortDimensionsMode | Set the dimensions mode of the input port indexed by pIdx |
ssSetInputPortDimsSameAsOutputPortDims | Set the dimensions of output port outIdx to be equal to the dimensions of input port inpIdx. This method is called from mdlSetWorkWidths. |
ssSetInputPortMatrixDimensions | Specify dimension information for an input port that accepts matrix signals |
ssSetInputPortVectorDimension | Specify dimension information for an input port that accepts vector signals |
ssSetInputPortWidth | Specify the width of an input port |
ssPruneNDMatrixSingletonDims | Prune trailing singleton dimensions |
ssSetCurrentOutputPortDimensions | Set the current size corresponding to dimension dIdx of the output signal at port pIdx. |
ssSetOutputPortDimensionInfo | Specify information about the dimensionality of an output port |
ssSetOutputPortDimensionsMode | Set the dimensions mode of the output port indexed by pIdx |
ssSetOutputPortMatrixDimensions | Specify dimension information for an output port that emits matrix signals |
ssSetOutputPortVectorDimension | Specify dimension information for an output port that emits vector signals |
ssSetOutputPortWidth | Specify the width of an output port |
ssSetOutputPortMatrixDimensions | Specify dimension information for an output port that emits matrix signals |
ssAddOutputDimsDependencyRule | Register a method to handle current dimensions update. |
ssAddVariableSizeSignalsRuntimeChecker | Register a method to check the current input dimensions |
ssAllowSignalsWithMoreThan2D | Enable S-function to work with multidimensional signals |
ssRegMdlSetInputPortDimensionsModeFcn | Register the method to handle dimensions mode propagation for each input port. |
ssSetDWorkRequireResetForSignalSize | Set the block flag for resetting the dIndex Dwork size upon subsystem reset. |
ssSetSignalSizesComputeType | Set the type of output dependency on the input signal. |
ssSetVectorMode | Specify the vector mode that an S-function supports |
ssGetCurrentInputPortDimensions | Get the current size of dimension dIdx of input port pIdx |
ssGetCurrentInputPortWidth | Get the total width (total number of elements) of the signal at input port pIdx |
ssGetInputPortDimensions | Get the dimensions of the signal accepted by an input port |
ssGetInputPortDimensionSize | Get the size of one dimension of the signal entering an input port |
ssGetInputPortDimensionsMode | Get the dimensions mode of the input port indexed by pIdx |
ssGetInputPortNumDimensions | Get the dimensionality of the signals accepted by an input port |
ssGetInputPortWidth | Get the width of an input port |
ssGetCurrentOutputPortDimensions | Get the current size of dimension dIdx of the signal at output port pIdx. |
ssGetCurrentOutputPortWidth | Get the total width (total number of elements) of the signal at output port pIdx. |
ssGetOutputPortDimensions | Get the dimensions of the signal leaving an output port |
ssGetOutputPortDimensionSize | Get the size of one dimension of the signal leaving an output port |
ssGetOutputPortDimensionsMode | Get the dimensions mode of the output port indexed by pIdx |
ssGetOutputPortNumDimensions | Get the number of dimensions of an output port |
ssGetOutputPortWidth | Get the width of an output port |
Signal Region
ssCallSelectedSignalsFcn | Invoke the selected signals function for an S-function |
ssCallSigListCreateFcn | Invoke the signal list creation function for an S-function |
ssCallSigListDestroyFcn | Invoke the signal list destruction function for an S-function |
ssCallSigListUnavailSigAlertFcn | Invoke the unavailable signal alert function for a signal list in an S-function |
ssCallGenericDestroyFcn | Invoke the generic destruction function for an S-function |
ssCallGetPortNameFcn | Get the name for a given port |
ssCallUnselectSigFcn | Invoke the signal deselection function for an S-function |
gsl_FirstReg | Get the first region of an element in a signal list |
gsl_nSigRegions | Get the number of regions in an element of a signal list |
gsl_nSigs | Get the number of signals in a signal list |
gsl_NumElements | Get the number of elements in an element of a signal list |
gsl_PortObj | Get the port associated with an element of a signal list |
gsl_TieWrap | Determine whether an element in a signal list is contiguous |
gsr_Complex | Determine whether the data in a signal region is complex |
gsr_currDims | Access the current dimensions for a variable-size signal in a signal region |
gsr_data | Access the data in a signal region |
gsr_DataType | Get the Simulink data type identifier for a region |
gsr_DataTypeSize | Get the size of a single real value in a signal region |
gsr_Dims | Access the values in the dimensions vector for a signal region |
gsr_nEls | Get the number of elements in a region |
gsr_NextReg | Get next region in the corresponding signal list |
gsr_NumDims | Get the number of dimensions of the data in a signal region |
gsr_portObj | Get the port associated with a signal region |
gsr_startIdx | Get the index for the element in a signal list at the start of a region |
gsr_status | Determine whether signal in a signal region is available |
gsr_Unit | Get the Simulink unit identifier for a signal region |
gsr_M | Determine number of rows in matrix signal |
gsr_N | Get the number of rows in or width of a signal |
Block Dialog Parameters
ssGetDTypeIdFromMxArray | Get the data type of an S-function parameter |
ssGetNumSFcnParams | Get the number of parameters that an S-Function block expects |
ssGetSFcnParam | Get a parameter of an S-Function block |
ssGetSFcnParamsCount | Get the number of block dialog parameters that an S-Function block has |
ssSetNumSFcnParams | Specify the number of parameters that an S-Function block has |
ssSetSFcnParamTunable | Make a block parameter tunable |
ssSetSFcnParamUnit | Specify unit of S-function block parameter |
ssGetSFcnParamUnit | Get unit of S-function parameter |
Data Type and Sample Time
Sample Time
ssSetSampleTime | Set the period of a sample time |
ssSetInputPortSampleTime | Specify the sample time of an input port |
ssSetModelReferenceSampleTimeDefaultInheritance | Specify that a referenced model containing this S-function can inherit its sample time from its parent model |
ssSetModelReferenceSampleTimeDisallowInheritance | Specify that the use of this S-function in a referenced model prevents the referenced model from inheriting its sample time from its parent model |
ssSetModelReferenceSampleTimeInheritanceRule | Specify whether use of this S-function in a referenced model prevents the referenced model from inheriting its sample time from its parent model |
ssSetNumSampleTimes | Specify the number of sample times that an S-Function block has |
ssSetOffsetTime | Set the offset time of a block |
ssSetTNext | Set the time of the next sample hit |
ssSetControllableSampleTime | Register controllable sample time in a block |
ssSetNumTicksToNextHitForControllableSampleTime | Schedule number of steps to next event |
ssSetNeedAbsoluteTime | Register if a block requires absolute time |
ssSetTimeSource | Set source of time for asynchronous task |
ssGetInputPortSampleTime | Get the sample time of an input port |
ssGetInputPortSampleTimeIndex | Get the sample time index of an input port |
ssGetNumSampleTimes | Get the number of sample times that a block has |
ssGetOffsetTime | Get one of an S-function's sample time offsets. |
ssGetOutputPortSampleTime | Get the sample time of an output port |
ssGetOutputPortSampleTimeIndex | Get sample time index of output port |
ssGetPortBasedSampleTimeBlockIsTriggered | Determine whether a block that uses port-based sample times resides in a triggered subsystem |
ssGetSampleTime | Get one of an S-function's sample times. |
ssGetTNext | Get the time of the next sample hit |
ssSetParameterTuningCompliance | Specify sample time behavior and tunability for S-function blocks with port-based sample times |
ssGetParameterTuningCompliance | Get the sample time behavior and tunability for S-function blocks with port-based sample times |
ssIsContinuousTask | Determine whether a task is continuous |
ssIsSampleHit | Determine whether the sample time is hit |
ssIsSpecialSampleHit | Determine whether the sample time is hit |
ssSampleAndOffsetAreTriggered | Determine whether a sample time and offset value pair indicate a triggered sample time |
ssSampleAndOffsetAreTriggeredOrAsync | Determine whether a sample time and offset value pair indicate a triggered or asynchronous sample time |
ssSetAsyncTimerAttributes | declares that the Simulink block requires a timer |
ssSetAsyncTimerDataType | sets the data type of the asynchronous task |
ssSetAsyncTaskPriorities | sets the Simulink task priority |
Data Type
ssRegisterDataType | Register a custom data type |
ssRegisterDataTypeInteger | Register integer data type and return its data type ID |
ssRegisterTypeFromNamedObject | Register
a custom data type from a Simulink.AliasType ,
Simulink.NumericType , or Simulink.Bus
object. |
ssSetDataTypeSize | Set the size of a custom data type |
ssSetDataTypeZero | Set the zero representation of a data type |
ssSetInputPortDataType | Set the data type of an input port |
ssSetOutputPortDataType | Set the data type of an output port |
ssGetDataTypeId | Get the ID of a data type |
ssGetDataTypeIdAliasedThruTo | Get the base data type associated with a data type alias |
ssGetDataTypeIsInteger | Determine whether registered data type is integer |
ssGetDataTypeIsSpecifiedInteger | Determine whether registered data type is integer with specified signedness and word length |
ssGetDataTypeName | Get the name of a data type |
ssGetDataTypeSize | Get the size of a custom data type |
ssGetDataTypeZero | Get the zero representation of a data type |
ssGetInputPortDataType | Get the data type of an input port |
ssGetNumDataTypes | Get number of data types registered for this simulation, including built-in types |
ssGetOutputPortDataType | Get the data type of an output port |
ssGetOutputPortSignal | Get the vector of signal elements emitted by an output port |
ssGetSFcnParamDataType | Get the data type of a parameter for an S-Function block |
Buses
ssGetBusElementComplexSignal | Get the signal complexity for a bus element |
ssGetBusElementDataType | Get the data type identifier for a bus element |
ssGetBusElementDimensions | Get the dimensions of a bus element |
ssGetBusElementName | Get the name of a bus element |
ssGetBusElementNumDimensions | Get the number of dimensions for a bus element |
ssGetBusElementOffset | Get the offset from the start of the bus data type to a bus element |
ssGetNumBusElements | Get the number of elements in a bus signal |
ssGetSFcnParamName | Get the value of a block parameter for an S-function block |
ssIsDataTypeABus | Determine whether a data type identifier represents a bus |
ssRegisterTypeFromParameter | Register a data type that a parameter in the Simulink data type table specifies |
ssRegisterTypeFromNamedObject | Register
a custom data type from a Simulink.AliasType ,
Simulink.NumericType , or Simulink.Bus
object. |
ssSetBusInputAsStruct | Specify whether to convert the input bus signal for an S-function from virtual to nonvirtual |
ssSetBusOutputAsStruct | Specify whether the output bus signal from an S-function must be virtual or nonvirtual |
ssSetBusOutputObjectName | Specify the name of the bus object that defines the structure and type of the output bus signal |
Strings
ssGetInputStringLength | Get length of string from input port |
ssGetStringDataTypeMaxLength | Get maximum length of string data type |
ssIsStringDataType | Determine if data type is string |
ssReadInputString | Read C string from input port |
ssRegisterStringDataType | Register string data type |
ssWriteOutputString | Write C string to output port |
Run-Time Parameters
ssGetNumRunTimeParams | Get the number of run-time parameters created by this S-function |
ssGetRunTimeParamInfo | Get the attributes of a run-time parameter |
ssRegAllTunableParamsAsRunTimeParams | Register all tunable parameters as run-time parameters |
ssRegDlgParamAsRunTimeParam | Register a dialog parameter as a run-time parameter |
ssSetNumRunTimeParams | Specify the number of run-time parameters created by this S-function |
ssSetRunTimeParamInfo | Specify the attributes of a run-time parameter |
ssUpdateAllTunableParamsAsRunTimeParams | Update the values of run-time parameters to be the same as those of the corresponding tunable dialog parameters |
ssUpdateDlgParamAsRunTimeParam | Update a run-time parameter that corresponds to a dialog parameter |
ssUpdateRunTimeParamData | Update the value of a run-time parameter |
ssUpdateRunTimeParamInfo | Update the attributes of a run-time parameter |
Function-Call Subsystems, Simulink Functions, and Model Reference
Function-Call Subsystems
ssCallSystemWithTid | Call the update and outputs methods of a function-call subsystem |
ssDisableSystemWithTid | Disable a function-call subsystem connected to this S-Function block |
ssEnableSystemWithTid | Enable a function-call subsystem connected to this S-function |
ssGetCallSystemNumFcnCallDestinations | Get the number of function-call destinations. |
ssGetExplicitFCSSCtrl | Determine whether this S-function explicitly enables and disables the function-call subsystems that it invokes |
ssSetCallSystemOutput | Specify that an output port is issuing a function call |
ssSetExplicitFCSSCtrl | Specify whether this S-function explicitly enables and disables the function-call subsystem that it calls |
Simulink Functions
ssDeclareSimulinkFunction | Declare Simulink function with a given function prototype and scope. |
ssDeclareFunctionCaller | Declare Simulink function call with a given function prototype. |
ssCallSimulinkFunction | Call a declared Simulink function of a given function prototype at run time. |
ssQuerySimulinkFunction | Determine if function name is declared as a Simulink Function. |
ssGetSimulinkFunctionInput | Get a pointer to an input argument passed to a Simulink Function. |
ssGetSimulinkFunctionOutput | Get a pointer to an output argument passed to a Simulink Function. |
ssSetSimulinkFunctionArgComplexity | Declare complexity of a Simulink Function argument. |
ssSetSimulinkFunctionArgDataType | Declare data type of Simulink Function argument. |
ssSetSimulinkFunctionArgDimensions | Declare dimension of Simulink Function argument. |
Model Reference
ssRTWGenIsModelReferenceRTWTarget | Determine if the model reference Simulink Coder target is generating |
ssRTWGenIsModelReferenceSimTarget | Determine if the model reference simulation target is generating |
ssSetModelReferenceNormalModeSupport | Specify if S-function can be used in referenced model that simulates in normal mode |
ssSetModelReferenceSampleTimeDefaultInheritance | Specify that a referenced model containing this S-function can inherit its sample time from its parent model |
ssSetModelReferenceSampleTimeDisallowInheritance | Specify that the use of this S-function in a referenced model prevents the referenced model from inheriting its sample time from its parent model |
ssSetModelReferenceSampleTimeInheritanceRule | Specify whether use of this S-function in a referenced model prevents the referenced model from inheriting its sample time from its parent model |
ssSetSupportedForCodeReuseAcrossModels | Specify if S-function can be reused across models |
Interactions with Simulink Engine
Simulation Information
ssSetStateAbsTol | Set the absolute tolerance used by a variable-step solver for a specific S-function continuous state. |
ssSetBlockReduction | Request that the Simulink engine attempt to reduce a block |
ssSetOperatingPointCompliance | Specify how the software handles S-function operating point information when saving and restoring model operating point |
ssSetOperatingPointVisibility | Specify whether S-function operating point is accessible in model operating point |
ssSetSolverNeedsReset | Ask Simulink engine to reset solver |
ssSetSkipContStatesConsistencyCheck | Ask Simulink engine to skip continuous state consistency check |
ssSetStopRequested | Set the simulation stop requested flag |
ssGetBlockReduction | Determine whether a block has requested block reduction before the simulation has begun and whether it has actually been reduced after the simulation loop has begun |
ssGetErrorStatus | Get a character vector that identifies the last error |
ssGetFixedStepSize | Get the fixed step size of the model containing the S-function. |
ssGetMaxStepSize | Get the maximum step size used by the model containing the S-function. |
ssGetMinStepSize | Get the minimum step size used by the model containing the S-function. |
ssGetSimMode | Get the simulation mode of an S-Function block |
ssGetSimStatus | Get the current simulation status of an S-Function block |
ssGetSolverMode | Get the solver mode being used to solve the S-function |
ssGetSolverName | Get the name of the solver being used to solve the S-function |
ssGetStateAbsTol | Get the absolute tolerance used by the variable-step solver for a specified state |
ssGetStopRequested | Get the value of the simulation stop requested flag |
ssGetT | Get the current simulation time |
ssGetTaskTime | Get the current time for the current task |
ssGetTFinal | Get the simulation stop time |
ssGetTNext | Get the time of the next sample hit |
ssGetTStart | Get the simulation start time |
ssIsExternalSim | Determine if the model is running in external mode. |
ssIsFirstInitCond | Determine whether the simulation time is equal to the start time. |
ssIsModeUpdateTimeStep | Determine whether update to mode vector is allowed on time step |
ssIsMajorTimeStep | Determine whether the simulation is in a major step |
ssIsMinorTimeStep | Determine whether the simulation is in a minor step |
ssIsVariableStepSolver | Determine if a variable-step solver is being used to solve the S-function |
ssRTWGenIsAccelerator | Determine if the model is running in Accelerator mode. |
ssIsRapidAcceleratorActive | Determine whether the model is running in Rapid Accelerator mode |
Error Handling
ssGetErrorStatus | Get a character vector that identifies the last error |
ssGetLocalErrorStatus | Get a character vector that identifies the last error |
ssPrintf | Print a variable-content message |
ssSetErrorStatus | Report an error |
ssSetLocalErrorStatus | Report an error in a thread-safe manner |
ssWarning | Display a warning message |
Information and Options
ssSetOptions | Specify S-function options |
ssCallExternalModeFcn | Invoke the external mode function for an S-function |
ssGetSFunctionName | Get the name of the S-Function |
ssGetBlockDiagramName | Get the name of Simulink model the S-Function is in |
ssGetModelName | Get the model name |
ssGetPath | Get the path of a block |
ssGetUserData | Access user data |
ssSetExternalModeFcn | Specify the external mode function for an S-function |
ssSetPlacementGroup | Specify the name of the placement group of a block |
ssSetUserData | Specify user data |
ssSupportsMultipleExecInstances | Specify that a For Each Subsystem block supports an S-function operating inside the subsystem. |
State and Work Vector
Set Options for Block Dwork Vectors
ssSetNumDWork | Specify the number of Dwork vectors used by a block |
ssSetDWorkComplexSignal | Specify whether the elements of a Dwork vector are real or complex |
ssSetDWorkDataType | Specify the data type of a Dwork vector |
ssSetDWorkName | Specify the name of a Dwork vector |
ssSetDWorkUsageType | Specify how DWork vector is used in S-function |
ssSetDWorkUsedAsDState | Specify that a Dwork vector is used as a discrete state vector |
ssSetDWorkWidth | Specify the width of a Dwork vector |
Get Options for Block Dwork Vectors
ssGetNumDWork | Get the number of Dwork vectors used by a block |
ssGetDWork | Get a DWork vector |
ssGetDWorkComplexSignal | Determine whether the elements of a Dwork vector are real or complex numbers |
ssGetDWorkDataType | Get the data type of a Dwork vector |
ssGetDWorkName | Get the name of a Dwork vector |
ssGetDWorkUsageType | Determine how DWork vector is used in S-function |
ssGetDWorkUsedAsDState | Determine whether a Dwork vector is used as a discrete state vector |
ssGetDWorkWidth | Get the size of a Dwork vector |
ssGetdX | Get the derivatives of a block's continuous states |
Set Options for Block States
ssSetNumContStates | Specify the number of continuous states that a block has |
ssSetNumDiscStates | Specify the number of discrete states that a block has |
ssSetNumNonsampledZCs | Specify the number of states for which a block detects zero crossings that occur between sample points |
Get Options for Block States
ssGetContStates | Get a block's continuous states |
ssGetDiscStates | Get a block's discrete states |
ssGetRealDiscStates | Get a block's discrete state vector |
ssGetNonsampledZCs | Get the zero-crossing signal values |
ssGetNumContStates | Get the number of continuous states that a block has |
ssGetNumDiscStates | Get the number of discrete states that a block has |
ssGetNumNonsampledZCs | Get the size of the zero-crossing vector |
Options for Block Work Vectors
ssSetNumRWork | Specify the size of a block's floating-point work vector |
ssGetNumRWork | Get the size of a block's floating-point work vector |
ssGetRWork | Get a block's floating-point work vector |
ssGetRWorkValue | Get an element of a block's floating-point work vector |
ssSetRWorkValue | Set an element of a block's floating-point work vector |
ssSetNumIWork | Specify the size of a block's integer work vector |
ssGetNumIWork | Get the size of a block's integer work vector |
ssGetIWork | Get a block's integer work vector |
ssGetIWorkValue | Get an element of a block's integer work vector |
ssSetIWorkValue | Set an element of a block's integer work vector |
ssSetNumPWork | Specify the size of a block's pointer work vector |
ssGetNumPWork | Get the size of a block's pointer work vector |
ssGetPWork | Get a block's pointer work vector |
ssGetPWorkValue | Get a pointer from a block's pointer work vector |
ssSetPWorkValue | Set an element of a block's pointer work vector |
ssSetNumModes | Specify the size of the block's mode vector |
ssGetNumModes | Get the size of the mode vector |
ssGetModeVector | Get mode vector |
ssGetModeVectorValue | Get an element of a block's mode vector |
ssSetModeVectorValue | Set an element of a block's mode vector |
Code Generation
Get Code Generation Information
ssGetDWorkRTWIdentifier | Get the identifier used to declare a DWork vector in code generated from the associated S-function |
ssGetDWorkRTWIdentifierMustResolveToSignalObject | Get
a flag indicating if a DWork vector resolves to a Simulink.Signal
object |
ssGetDWorkRTWStorageClass | Get the storage class of a DWork vector in code generated from the associated S-function |
ssGetDWorkRTWTypeQualifier | Get
the C type qualifier (e.g., const ) used to declare a DWork vector
in code generated from the associated S-function |
ssGetPlacementGroup | Get the name of the placement group of a block |
ssRTWGenIsCodeGen | Identify any code generation that is not used by the Accelerator. |
Set Code Generation Information
ssSetArrayLayoutForCodeGen | Specify array layout of the S-function |
ssSetDWorkRTWIdentifier | Specify the identifier used to declare a DWork vector in code generated from the associated S-function |
ssSetDWorkRTWIdentifierMustResolveToSignalObject | Specify
if a DWork vector resolves to a Simulink.Signal object |
ssSetDWorkRTWStorageClass | Specify the storage class of a DWork vector in code generated from the associated S-function |
ssSetDWorkRTWTypeQualifier | Specify
the C type qualifier (e.g., const ) used to declare a DWork vector
in code generated from the associated S-function |
ssSetPlacementGroup | Specify the name of the placement group of a block |
Write Information to model.rtw
File
ssWriteRTW2dMatParam | Write
a matrix parameter to the
file |
ssWriteRTWMx2dMatParam | Write
a matrix parameter in MATLAB format to the
file |
ssWriteRTWMxVectParam | Write
a vector parameter in MATLAB format to the
file |
ssWriteRTWParameters | Write
tunable parameter information to the
file |
ssWriteRTWParamSettings | Write
values of nontunable parameters to the
file |
ssWriteRTWScalarParam | Write
a scalar parameter to the
file |
ssWriteRTWStr | Write
a character vector to the
file |
ssWriteRTWStrParam | Write
a character vector parameter to the
file |
ssWriteRTWStrVectParam | Write
a vector of character vector parameters to the
file |
ssWriteRTWVectParam | Write
a vector parameter to the
file |
ssWriteRTWWorkVect | Write
work vectors to the
file |
Timers
ssSetNeedAbsoluteTime | Register if a block requires absolute time |
ssGetNeedAbsoluteTime | Check if the S-function block has registered that it requires absolute time |
ssSetNeedElapseTime | Register if a block requires elapsed time |
ssGetNeedElapseTime | Check if the S-function block has registered that it requires elapsed time |
ssGetElapseTime | Get the value of elapse time counter associated with the S-function |
ssGetElapseTimeCounter | Get the integer value of the elapse time counter associated with the S-function |
ssGetElapseTimeResolution | Get the sample time of the elapse time counter associated with the S-function |
ssGetElapseTimeCounterDtype | Get the data type of the elapse time counter associated with the S-function |
Topics
- Input and Output Ports
Create input and output ports on a C/C++ S-function block.
- Pass Dialog Parameters to S-Functions
Process parameters via the C/C++ S-function block dialog box.
- Specify S-Function Sample Times
Specify the rate at which a block operates in C/C++ S-functions.
- DWork Vector Basics
Learn the key concepts of DWork vectors.
- Configure Custom Data Types
Configure custom data types for the values of a block's signals and parameters in C/C++ S-functions.
- Implement Function-Call Subsystems with S-Functions
Create function-call subsystems with S-functions.
- Using Function-Call Subsystems
Create a subsystem that executes with a function call.
- Create and Update S-Function Run-Time Parameters
Create and update run-time parameters in C/C++ S-functions.
- Guidelines for Writing Thread-Safe S-Functions
Consider these guidelines when you want to make your S-functions to be thread-safe.
- Use C/C++ S-Functions as Sim Viewing Devices in External Mode
Specify C/C++ S-function as a sim viewing device for use in external mode.
- Handle Errors in S-Functions
Handle unexpected events in S-functions.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)