MATLAB: Change/reset initial state values in a level 2 C-mex S-function

changeinitial conditionsresetsimulinkstate values

Hi all! I'm creating a simulation with level 2 c-mex s-function, and I need to change some state values, when some conditions are verified. How can I do that? I read about the enabled subsystem, but I don't know how it works, and also I don't know if there is something faster that do the same thing.
Can you help me?
Thanks in advance!

Best Answer

If you wrote or have the c-code for the s-function you can simply add another input and write a conditional to reset the data when that condition is verified.