ssDeclareFunctionCaller - Declare Simulink function call with a given function prototype. - MATLAB (original) (raw)
Declare Simulink function call with a given function prototype.
Syntax
void ssDeclareFunctionCaller(SimStruct *S, char *fcnPrototype)
Arguments
S
SimStruct that represents an S-Function block.
fcnPrototype
Function prototype of the Simulink® function.
Description
ssDeclareFunctionCaller
is required to declare the Simulink function prototype to be called in the compile-time methodmdlInitializeSizes
. ssCallSimulinkFunction
calls a declared Simulink function at run-time.
Examples
Note
ssDeclareFunctionCaller
may only be called inmdlInitializeSizes
.
Example 1
char fcnPrototype[] = "y = timestwo(u)"; ssDeclareFunctionCaller(S, fcnPrototype);
Example 2
To call a Simulink function outside of the model hierarchy with non-default argument specifications (not real double scalars), use ssDeclareSimulinkFunction to declare the Simulink function with NULL
as thefcnPtr
argument. Use the following macros to set the datatype, dimension, and complexity: ssSetSimulinkFunctionArgDataType, ssSetSimulinkFunctionArgDimensions, ssSetSimulinkFunctionArgComplexity. UsessDeclareFunctionCaller
to declare the function caller.
char fcnPrototype[] = "y=foo(u)";
/* Declare the external function as NULL*/ ssDeclareSimulinkFunction(S, fcnPrototype, NULL, SS_GLOBAL_VISIBILITY);
/* Specify function argument dimensions*/ size_t dims[1] = {3}; ssSetSimulinkFunctionArgDimensions(S, "foo", "u", 1, dims); ssSetSimulinkFunctionArgDimensions(S, "foo", "y", 1, dims);
/* Call an external function*/ ssDeclareFunctionCaller(S, fcnPrototype);
Version History
Introduced in R2018a