Compute the signals that this block emits
Yes
C, C++
#define MDL_OUTPUTS
void mdlOutputs(SimStruct *S, int_T tid)
S
SimStruct representing an S-Function block.
tid
Task ID.
The Simulink® engine invokes this required method at each simulation time step. The method should compute the S-function's outputs at the current time step and store the results in the S-function's output signal arrays.
The tid
(task ID) argument specifies the
task running when the mdlOutputs
routine is invoked.
You can use this argument in the mdlOutputs
routine
of a multirate S-Function block to encapsulate task-specific blocks
of code (see Multirate S-Function Blocks).
Use the UNUSED_ARG
macro if the S-function
does not contain task-specific blocks of code to indicate that the tid
input
argument is required but not used in the body of the callback. To
do this, insert the line
UNUSED_ARG(tid)
after the declarations in mdlOutputs
.
Note
If you have Simulink
Coder™, when generating code for a noninlined
S-function that contains this method, make sure the method is not
wrapped in a #if defined(MATLAB_MEX_FILE)
statement.
For example:
#if defined(MATLAB_MEX_FILE) static void mdlOutputs(SimStruct *S) { /* Add mdlOutputs code here * } #endif
The define
statement makes the mdlOutputs
method
available only to a MATLAB® MEX file. If the S-function is not
inlined, the Simulink
Coder product cannot use this method,
resulting in link or run-time errors.
For an example of an mdlOutputs
routine that
works with multiple input and output ports, see sfun_multiport.c
.