User`s guide

3 Writing S-Functions As C-MEX files
3-20
The length of the various signals and vectors is configured in the
mdlInitializeSizes routine. The signals as well as their length can be
accessed in S-function routi nes that are called during the simulation loop.
During t he simulation loop, accessing the input signals is performed using:
InputRealPtrs uPtrs = ssGetInputPortRealSignalPtrs(S,portIndex)
This is an array of pointers, where portIndex starts at 0. There is one for each
input port. To access an element of this signal you must use:
*uPtrs[element]
as described by this figure:
Figure 3-5: Accessing Input Data from S-Function Input Ports
Note that input array pointers may point at noncontig uous places in memory.
You can retrieve the output signal by using this code:
real_T *y = ssGetOutputPortSignal(S,outputPortIndex);
S-function
Block
Input 1
Input 2
uPtrs0
...
...
Block I/O
Vector
InputRealPtrs uPtrs0 = ssGetInputPortRealSignalPtrs(S,0)
To Access Input 1:
uPtrs1
...
InputRealPtrs uPtrs1 = ssGetInputPortRealSignalPtrs(S,1)
To Access Input 2: