Matlab S-Function: Wie man behebt, dass mdlStart() nicht aufgerufen wird

Problem

Sie haben eine S-Funktion in Matlab/Simulink und die Funktion mdlStart wird nicht aufgerufen:

sfunc_mdlstart_example.cpp
static void mdlStart(SimStruct *S)
{
    // This code is never executed
}

Lösung

Sie müssen #define MDL_START in Ihrer S-Funktions-Datei vor Ihrer mdlStart()-Funktion definieren:

mdlstart_fix.cpp
#define MDL_START
static void mdlStart(SimStruct *S)
{
    // This code is now executed
}

Check out similar posts by category: Matlab/Simulink