ssGetOutputPortSignal - Get the vector of signal elements emitted by an output port
Syntax
void *ssGetOutputPortSignal(SimStruct *S, int_T port)
Arguments
- S
SimStruct representing an S-Function block.
- port
Index of an output port.
Returns
A pointer (void *) to the vector of signal
elements output at the port specified by the index port.
Description
Use in any simulation loop routine, mdlInitializeConditions,
or mdlStart to obtain a vector of signal elements
emitted by an output port.
Note
You cannot use ssGetOutputPortSignal anywhere
except in mdlOutputs if you have specified that
the output ports are reusable using ssSetOutputPortOptimOpts.
For example, if the outputs have been specified as reusable with the SS_REUSABLE_AND_LOCAL flag,
the mdlUpdate routine errors out when it tries
to access output memory that is unavailable. |
Note
If the port outputs a signal of type double (real_T),
use ssGetOutputPortRealSignal to get the signal
vector and avoid the need to type cast the output of ssGetOutputPortSignal. |
Languages
C, C++
Example
Assume that the output port data types are int16_T.
nOutputPorts = ssGetNumOutputPorts(S);
for (i = 0; i < nOutputPorts; i++) {
int16_T *y = (int16_T *)ssGetOutputPortSignal(S,i);
int_T ny = ssGetOutputPortWidth(S,i);
for (j = 0; j < ny; j++) {
SomeFunctionToFillInOutput(y[j]);
}
}
See the S-function matlabroot/simulink/src/sfun_port_constant.c used
in sfcndemo_port_constant.mdl for
a complete example that uses this function.
See Also
ssGetOutputPortRealSignal
 | ssGetOutputPortSampleTimeIndex | | ssGetOutputPortWidth |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit