| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Yes
#define MDL_OUTPUTS
void mdlOutputs(SimStruct *S, int_T tid)
Outputs(s)
Instance of Simulink.MSFcnRunTimeBlock class representing the Level-2 M-file S-Function block.
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 mdlOutports 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 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 Real-Time Workshop product cannot use this method, resulting in link or run-time errors. |
In a Level-2 M-file S-function, the Outputs method calculates the S-function's outputs at the current time step and store the results in the run-time object's OutputPort(n).Data property. In addition, for S-functions with a variable sample time, the Outputs method computes the next sample time hit.
Use the run-time object method IsSampleHit to determine if the current simulation time is one at which a task handled by this block is active. For port-based sample times, use the IsSampleHit property of the run-time object's InputPort or OutputPort methods to determine if the port produces outputs or accepts inputs at the current simulation time step.
Set the run-time object's NextTimeHit property to specify the time of the next sample hit for variable sample-time S-functions.
For an example of an mdlOutputs routine that works with multiple input and output ports, see matlabroot/toolbox/simulink/simdemos/simfeatures/src/ sfun_multiport.c.
C, C++, M
ssGetOutputPortComplexSignal, ssGetOutputPortRealSignal, ssGetOutputPortSignal
![]() | mdlInitializeSizes | mdlProcessParameters | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |