Products & Services Industries Academia Support User Community Company

Learn more about Simulink   

mdlOutputs - Compute the signals that this block emits

Required

Yes

C Syntax

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

C Arguments

S

SimStruct representing an S-Function block.

tid

Task ID.

M Syntax

Outputs(s)

M Arguments

s

Instance of Simulink.MSFcnRunTimeBlock class representing the Level-2 M-file S-Function block.

C 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 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.

M Description

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.

C Example

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.

Languages

C, C++, M

See Also

ssGetOutputPortComplexSignal, ssGetOutputPortRealSignal, ssGetOutputPortSignal

  


Related Products & Applications

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