User`s guide

Converting Level 1 C MEX S-Functions to Level 2
3-119
If your S -function has a nonempty mdlInitializeConditions, then update
it to the following form
#define MDL_INITIALIZE_CONDITIONS
static void mdlInitializeConditions(SimStruct *S)
{
}
otherwise, delete the function.
- The continuous states are accessed using
ssGetContStates.ThessGetX
macro has been removed.
- The discrete states are accessed using
ssGetRealDiscStates(S).The
ssGetX macro has been removed.
- For mixed continuous and discrete state S-functions, the state vector no
longer consists of thecontinuousstatesfollowedby thediscretestates.The
states are saved in separate vectors and hence may not be contiguous in
memory.
The
mdlOutputs prototype has changed from
static void mdlOutputs( real_T *y, const real_T *x,
const real_T *u, SimStruct *S, int_T tid)
to:
static void mdlOutputs(SimStruct *S, int_T tid)
Since y, x,anduare not explicitly passed into Level-2 S-functions, you must
use:
-
ssGetInputPortRealSignalPtrs to access inputs.
-
ssGetOutputPortSignal to access the outputs.
-
ssGetContStates or ssGetRealDiscStates to access the states.
The
mdlUpdate function prototype has been changed from
void mdlUpdate(real_T *x, real_T *u, Simstruct *S, int_T tid)
to:
void mdlUpdate(SimStruct *S, int_T tid)