For those who may look into this question in the future, I found the answer. mdlUpdate
doesn't count as Direct Feedthrough. However, if you try to access the input port signal at the first time step, that will lead to a Segmentation Violation (the Mathworks documentation suggests that the error might be different for different computers).
The trick is to use ssIsFirstInitCond(S)
to acquire whether the compiler is at the first time step or not, and avoid doing any assignment in the first step.
My code looks like this:
#define MDL_UPDATE
#if defined(MDL_UPDATE)
static void mdlUpdate(SimStruct *S)
{UNUSED_ARG(tid);
if(!ssIsFirstInitCond(S))
{
real_T *u1 = (real_T *) ssGetInputPortSignal(S)[0];
double *P1 = (double *) ssGetPWork(S)[0];
// assign values here
}
}
#endif
Also, note that mdlUpdate
is called only in the major time steps