Documentation Center

  • Trial Software
  • Product Updates

Contents

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   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.

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 sfun_port_constant.csfun_port_constant.c used in sfcndemo_port_constantsfcndemo_port_constant for a complete example that uses this function.

Was this topic helpful?