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
ssgetinput_example.cpp
real_T *input = ssGetInputPortSignal(S, 0);- The input port might not be connected. In this case,
ssGetInputPortSignal()will returnNULLornullptr. You can check if the port is connected usingssGetInputPortConnected():
example.cpp
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 returnNULLornullptr. You should call it in themdlStart()ormdlUpdate()functions instead.
Check out similar posts by category:
Matlab/Simulink
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow