Memory block alternative that ISN'T fixed in minor time step?
3 views (last 30 days)
Show older comments
I have a model with some inputs that are fed into a CMEX S-Function via the Memory block, and the S-Function provides outputs based on these inputs, and those inputs are fed back into the S-Function. Classic algebraic loop scenario. I was using a memory block to prevent this because our solver is usually variable-time step
According to the Mathworks documentation the Memory Block, and the Unit Delay block also, are fixed in minor time step in terms of their outputs. I realize that the inputs can be either discrete or continuous, but the output will only be continuous in the major time step, and fixed in the minor one.
Now, for various reasons, it is important to us that everything in the model get updated in the minor and major time steps. I came up with a way of using the PWork vector to store the previous value of state points and forward them to the CMEX S-Function that we use. This prevents algebraic loops from occuring and also ensures continuous in minor time step, but is not as elegant as I would like.
Does anyone have any alternative suggestions?
PS: As an aside, I believe that it is better to use the Memory block regardless of if my solver is Fixed Step or Variable Step, because it will internally just become a Unit Delay block for Fixed Step solvers. Is this assumption correct?
Find more on Configure C/C++ S-Function Features in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!