ssCallSimulinkFunction
Call a declared Simulink function of a given function prototype at run time.
Syntax
void ssCallSimulinkFunction(SimStruct *S, char *scopedFcnName, int_T numInArgs, _ssFcnCallExecArgInfo* execInArgs, int_T numOutArgs, _ssFcnCallExecArgInfo* execOutArgs)
Arguments
SSimStruct that represents an S-Function block.
scopedFcnNameScoped name of a Simulink® function. Function must have previously been declared using
ssDeclareFunctionCaller.numInArgsNumber of input arguments.
execInArgsPointer to a valid array of
_ssFcnCallExecArgInfostruct. The struct fieldsdataPtranddataSizeare associated with a pre-assigned memory buffer corresponding to the Simulink function argument.numOutArgsNumber of output arguments.
execOutArgsPointer to a valid array of
_ssFcnCallExecArgInfostruct. The struct fieldsdataPtranddataSizeare associated with a pre-assigned memory buffer corresponding to the Simulink function argument.
Note
The _ssFcnCallExecArgInfo struct type is defined in
simstruc_types.h as the following:
typedef struct _ssFcnCallExecArgInfo_tag {
void* dataPtr;
int_T dataSize;
void* reserved;
} _ssFcnCallExecArgInfo;Returns
No return value.
Description
ssCallSimulinkFunction calls a declared Simulink function at run-time. Before using it, ssDeclareFunctionCaller is required to declare the Simulink function prototype to be called in the compile-time method
mdlInitializeSizes. To implement a Simulink function with S-Function API, ssDeclareSimulinkFunction can specify the Simulink function implementation at compile
time.ssCallSimulinkFunction calls a declared Simulink function at run-time.
Examples
_ssFcnCallExecArgInfo inArgs[1];
_ssFcnCallExecArgInfo outArgs[1];
double inArray[3] = {1, 2, 3};
double outArray[3] = {0, 0, 0};
inArgs [0].dataPtr = inArray;
inArgs [0].dataSize = sizeof(inArray);
outArgs[0].dataPtr = outArray;
outArgs[0].dataSize = sizeof(outArray);
ssCallSimulinkFunction(S, "timestwo", 1, inArgs, 1, outArgs);Languages
C, C++
See Also
ssDeclareFunctionCaller, ssDeclareSimulinkFunction, ssGetSimulinkFunctionInput, ssGetSimulinkFunctionOutput, ssQuerySimulinkFunction, ssSetSimulinkFunctionArgComplexity, ssSetSimulinkFunctionArgDataType, ssSetSimulinkFunctionArgDimensions
Version History
Introduced in R2018a