This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Get the vector of signal elements emitted by an output port


void *ssGetOutputPortSignal(SimStruct *S, int_T port)



SimStruct representing an S-Function block.


Index of an output 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 mdlOutputs. 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++) {

See the S-function sfun_port_constant.c used in sfcndemo_port_constant for a complete example that uses this function.

Introduced before R2006a

Was this topic helpful?