Writing S-Functions | ![]() ![]() |
Specify that an output port is reusable.
Syntax
ssSetOutputPortReusable(SimStruct *S,outputPortIdx,isReusable
)
Arguments
S
SimStruct representing an S-function block.
isReusable
Value specifying reusability of port
Description
Use in mdlInitializeSizes
(after ssSetNumOutputPorts
) to specify whether output ports have a test point. This macro can take on two values:
isReusable=0
) -- specifies that the output port is not reusable. This is the default.isReusable=1
) -- specifies that the output port is reusable.In Simulink, reusable signals share the same memory space. When this macro is turned on, the output port signal to the S-function may be reused by other signals in the model. This reuse results in less memory use during Simulink simulation and more efficiency in the Real-Time Workshop generated code.
When you mark an output port as reusable, your S-function must update the output once in mdlOutputs
. It cannot expect the previous output value to be persistent.
By default, the output port signals are not reusable. This forces Simulink's simulation engine (and the Real-Time Workshop) to allocate global memory for these output port signals. Hence this memory is only written to by your S-function and persists between model execution steps.
Languages
See Also
ssSetNumOutputPorts, ssSetInputPortReusable
![]() | ssSetOutputPortOffsetTime | ssSetOutputPortSampleTime | ![]() |