Main Content

ssGetOutputPortRealSignal

Get a pointer to an output signal of type double (real_T)

Syntax

real_T *ssGetOutputPortRealSignal(SimStruct *S, int_T port)

Arguments

S

SimStruct that represents an S-Function block.

port

Index of an output port.

Returns

A contiguous real_T vector of length equal to the width of the output port.

Description

Use in any simulation loop routine, mdlInitializeConditions, or mdlStart to access an output port signal where the output port index starts at 0 and must be less than the number of output ports.

Note

You cannot use ssGetOutputPortRealSignal 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.

Languages

C, C++

Examples

To write to all output ports, you would use

int_T i,j;
int_T nOutputPorts = ssGetNumOutputPorts(S);
for (i = 0; i < nOutputPorts; i++) {
  real_T *y = ssGetOutputPortRealSignal(S,i);
  int_T  ny = ssGetOutputPortWidth(S,i);
  for (j = 0; j < ny; j++) {
    y[j] = SomeFunctionToFillInOutput();
  }
}

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

Version History

Introduced before R2006a