For example, I would like to track the previous value of each input signal element entering one of the ports of my S-function block. I would like to obtain this type of persistent storage of variables, and I wonder if I should use static or global variables. Doing this could lead to a reentrancy problem that I would like to avoid.
MATLAB: How to work with static or global variables in CMEX S-functions? What are work vectors
%sfunctionglobalsfunctionsimulinkvectorswork
Related Question
- How to specify the identifier of the DWork vector when writing an S-function in Simulink 6.4 (R2006a) such that on code generation it is accessed via its identifier and not as a field of the DWork structure
- How does a C-MEX S-function manage its memory when there are multiple instances of it in a model
- How to allocate and free memory for a PWork vector in a C-MEX S-function
- In Simulink, if I have a C++ S-function with classes containing static attributes, will multiple instances of the S-function cause problems between the static variables
Best Answer