Matlab S-Function: Why does ssGetInputPortSignal() return NULL?
There are several different reasons why ssGetInputPortSignal()
returns NULL
or nullptr
?
- You might be passing bad parameters to
ssGetInputPortSignal()
. A typical use would be
real_T *input = ssGetInputPortSignal(S, 0);
- The input port might not be connected. In this case,
ssGetInputPortSignal()
will returnNULL
ornullptr
. You can check if the port is connected usingssGetInputPortConnected()
:
if (!ssGetInputPortConnected(S, 0)) {
mexPrintf("Input port 0 is not connected\n");
}
- You might be calling
ssGetInputPortSignal()
in the wrong place. For example, if you call it in themdlInitializeSizes()
ormdlOutputs()
functions, it will returnNULL
ornullptr
. You should call it in themdlStart()
ormdlUpdate()
functions instead.