Main Content

mdlOutputs

Compute the signals that this block emits

Required

Yes

Languages

C, C++

Syntax

#define MDL_OUTPUTS
void mdlOutputs(SimStruct *S, int_T tid)

Arguments

S

SimStruct representing an S-Function block.

tid

Task ID.

Description

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.

Examples

For an example of an mdlOutputs routine that works with multiple input and output ports, see sfun_multiport.c.

Version History

Introduced before R2006a