Writing S-Functions | ![]() ![]() |
Specify that an output port is reusable.
Syntax
Arguments
S
SimStruct representing an S-Function block.
outputPortIdx
Index of the output port whose reusability is being set.
Value specifying reusability of the port.
Description
Use in mdlInitializeSizes
(after ssSetNumOutputPorts
) to specify whether output ports have a test point. This macro can take one of 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. This macro allows an S-function to tell Simulink that it can store the S-function's outputs temporarily in memory used for storing other signals in the model. This reuse results in less memory use during 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.
Note If you want to allow users to connect the output of your S-function to a Merge block, you must use this macro to specify that your S-function's output ports are reusable. |
Languages
See Also
ssSetNumOutputPorts, ssSetInputPortReusable
![]() | ssSetOutputPortOffsetTime | ssSetOutputPortSampleTime | ![]() |