| Contents | Index |
void *ssGetOutputPortSignal(SimStruct *S, int_T port)
A pointer (void *) to the vector of signal elements output at the port specified by the index port.
Use in any simulation loop routine, mdlInitializeConditions, or mdlStart to obtain a vector of signal elements emitted by an output port.
Note If you have specified that the output ports are reusable using ssSetOutputPortOptimOpts, then you cannot use ssGetOutputPortSignal anywhere except in mdlUpdate. For example, if the outputs have been specified as reusable with the SS_REUSABLE_AND_LOCAL flag, the mdlUpdate routine errors out because 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. |
C, C++
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 sfun_port_constant.c used in sfcndemo_port_constant.mdl for a complete example that uses this function.

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